Skip to content

Commit ab70516

Browse files
committed
Use ESM
1 parent 71e4cb0 commit ab70516

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

index.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
'use strict'
2-
3-
var visit = require('unist-util-visit')
4-
var toString = require('nlcst-to-string')
5-
var syllable = require('syllable')
6-
var daleChall = require('dale-chall')
7-
var spache = require('spache')
8-
var daleChallFormula = require('dale-chall-formula')
9-
var ari = require('automated-readability')
10-
var colemanLiau = require('coleman-liau')
11-
var flesch = require('flesch')
12-
var smog = require('smog-formula')
13-
var gunningFog = require('gunning-fog')
14-
var spacheFormula = require('spache-formula')
15-
16-
module.exports = readability
1+
import visit from 'unist-util-visit'
2+
import toString from 'nlcst-to-string'
3+
import syllable from 'syllable'
4+
import {daleChall} from 'dale-chall'
5+
import {spache} from 'spache'
6+
import daleChallFormula from 'dale-chall-formula'
7+
import ari from 'automated-readability'
8+
import colemanLiau from 'coleman-liau'
9+
import flesch from 'flesch'
10+
import smog from 'smog-formula'
11+
import gunningFog from 'gunning-fog'
12+
import spacheFormula from 'spache-formula'
1713

1814
var origin = 'retext-readability:readability'
1915
var defaultTargetAge = 16
@@ -26,7 +22,7 @@ var round = Math.round
2622
var ceil = Math.ceil
2723
var sqrt = Math.sqrt
2824

29-
function readability(options) {
25+
export default function retextReadability(options) {
3026
var settings = options || {}
3127
var targetAge = settings.age || defaultTargetAge
3228
var threshold = settings.threshold || defaultThreshold
@@ -58,8 +54,8 @@ function readability(options) {
5854

5955
if (wordCount >= minWords) {
6056
counts = {
61-
complexPolysillabicWord: complexPolysillabicWord,
62-
polysillabicWord: polysillabicWord,
57+
complexPolysillabicWord,
58+
polysillabicWord,
6359
unfamiliarWord: wordCount - familiarWordCount,
6460
difficultWord: wordCount - easyWordCount,
6561
syllable: totalSyllables,

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,22 @@
3838
"Josiah Sprague <[email protected]>",
3939
"Sylvan Swierkosz <[email protected]>"
4040
],
41+
"sideEffects": false,
42+
"type": "module",
43+
"main": "index.js",
4144
"files": [
4245
"index.js"
4346
],
4447
"dependencies": {
4548
"automated-readability": "^1.0.0",
4649
"coleman-liau": "^1.0.0",
47-
"dale-chall": "^1.0.0",
50+
"dale-chall": "^2.0.0",
4851
"dale-chall-formula": "^1.0.0",
4952
"flesch": "^1.0.0",
5053
"gunning-fog": "^1.0.0",
5154
"nlcst-to-string": "^2.0.0",
5255
"smog-formula": "^1.0.0",
53-
"spache": "^1.1.0",
56+
"spache": "^2.0.0",
5457
"spache-formula": "^1.0.0",
5558
"syllable": "^4.0.0",
5659
"unist-util-visit": "^2.0.0"
@@ -62,7 +65,7 @@
6265
"remark-preset-wooorm": "^8.0.0",
6366
"retext": "^7.0.0",
6467
"tape": "^5.0.0",
65-
"xo": "^0.37.0"
68+
"xo": "^0.39.0"
6669
},
6770
"scripts": {
6871
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
@@ -80,8 +83,9 @@
8083
},
8184
"xo": {
8285
"prettier": true,
83-
"esnext": false,
8486
"rules": {
87+
"no-var": "off",
88+
"prefer-arrow-callback": "off",
8589
"unicorn/no-array-callback-reference": "off",
8690
"unicorn/prefer-includes": "off"
8791
}

test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict'
2-
3-
var test = require('tape')
4-
var retext = require('retext')
5-
var readability = require('.')
1+
import test from 'tape'
2+
import retext from 'retext'
3+
import readability from './index.js'
64

75
test('readability', function (t) {
86
retext()

0 commit comments

Comments
 (0)