@@ -18,6 +18,9 @@ Applies [Dale—Chall][dale-chall],
18
18
19
19
## Install
20
20
21
+ This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
22
+ Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d.
23
+
21
24
[ npm] [ ] :
22
25
23
26
``` sh
@@ -39,19 +42,22 @@ discovered, with a surface temperature of 200,000 kelvin
39
42
…and our script, ` example.js ` , looks like this:
40
43
41
44
``` js
42
- var vfile = require (' to-vfile' )
43
- var report = require (' vfile-reporter' )
44
- var unified = require (' unified' )
45
- var english = require (' retext-english' )
46
- var stringify = require (' retext-stringify' )
47
- var readability = require (' retext-readability' )
45
+ import {readSync } from ' to-vfile'
46
+ import {reporter } from ' vfile-reporter'
47
+ import {unified } from ' unified'
48
+ import retextEnglish from ' retext-english'
49
+ import retextStringify from ' retext-stringify'
50
+ import retextReadability from ' retext-readability'
51
+
52
+ const file = readSync (' example.txt' )
48
53
49
54
unified ()
50
- .use (english)
51
- .use (readability)
52
- .use (stringify)
53
- .process (vfile .readSync (' example.txt' ), function (err , file ) {
54
- console .error (report (err || file))
55
+ .use (retextEnglish)
56
+ .use (retextReadability)
57
+ .use (retextStringify)
58
+ .process (file)
59
+ .then ((file ) => {
60
+ console .error (reporter (file))
55
61
})
56
62
```
57
63
@@ -67,10 +73,10 @@ example.txt
67
73
By default, the target age is 16, but ages can be set, for example, to 6:
68
74
69
75
``` diff
70
- .use(english )
71
- - .use(readability )
72
- + .use(readability , {age: 6})
73
- .use(stringify )
76
+ .use(retextEnglish )
77
+ - .use(retextReadability )
78
+ + .use(retextReadability , {age: 6})
79
+ .use(retextStringify )
74
80
```
75
81
76
82
Now, running ` node example ` once more yields:
@@ -85,7 +91,10 @@ example.txt
85
91
86
92
## API
87
93
88
- ### ` retext().use(readability[, options]) `
94
+ This package exports no identifiers.
95
+ The default export is ` retextReadability ` .
96
+
97
+ ### ` unified().use(retextReadability[, options]) `
89
98
90
99
Detect possibly hard to read sentences.
91
100
0 commit comments