-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.js
More file actions
29 lines (25 loc) · 757 Bytes
/
build.js
File metadata and controls
29 lines (25 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import fs from 'node:fs/promises'
import fetch from 'node-fetch'
import {fromHtml} from 'hast-util-from-html'
import {selectAll} from 'hast-util-select'
import {toString} from 'hast-util-to-string'
const response = await fetch(
'https://www.readabilityformulas.com/articles/spache-formula-word-list.php'
)
const text = await response.text()
const tree = fromHtml(text)
const values = selectAll('td p', tree)
.map((d) => toString(d))
.join('|')
.replace(/\\/g, "'")
.trim()
.toLowerCase()
.split(/\s*\|\s*/g)
.filter(Boolean)
.sort()
await fs.writeFile(
'index.js',
'/**\n * List of familiar American-English words: Revised Spache (1974)\n*/\nexport const spache = ' +
JSON.stringify([...new Set(values)], null, 2) +
'\n'
)