Skip to content

Commit

Permalink
Use ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 18, 2021
1 parent 71e4cb0 commit ab70516
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
34 changes: 15 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
'use strict'

var visit = require('unist-util-visit')
var toString = require('nlcst-to-string')
var syllable = require('syllable')
var daleChall = require('dale-chall')
var spache = require('spache')
var daleChallFormula = require('dale-chall-formula')
var ari = require('automated-readability')
var colemanLiau = require('coleman-liau')
var flesch = require('flesch')
var smog = require('smog-formula')
var gunningFog = require('gunning-fog')
var spacheFormula = require('spache-formula')

module.exports = readability
import visit from 'unist-util-visit'
import toString from 'nlcst-to-string'
import syllable from 'syllable'
import {daleChall} from 'dale-chall'
import {spache} from 'spache'
import daleChallFormula from 'dale-chall-formula'
import ari from 'automated-readability'
import colemanLiau from 'coleman-liau'
import flesch from 'flesch'
import smog from 'smog-formula'
import gunningFog from 'gunning-fog'
import spacheFormula from 'spache-formula'

var origin = 'retext-readability:readability'
var defaultTargetAge = 16
Expand All @@ -26,7 +22,7 @@ var round = Math.round
var ceil = Math.ceil
var sqrt = Math.sqrt

function readability(options) {
export default function retextReadability(options) {
var settings = options || {}
var targetAge = settings.age || defaultTargetAge
var threshold = settings.threshold || defaultThreshold
Expand Down Expand Up @@ -58,8 +54,8 @@ function readability(options) {

if (wordCount >= minWords) {
counts = {
complexPolysillabicWord: complexPolysillabicWord,
polysillabicWord: polysillabicWord,
complexPolysillabicWord,
polysillabicWord,
unfamiliarWord: wordCount - familiarWordCount,
difficultWord: wordCount - easyWordCount,
syllable: totalSyllables,
Expand Down
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,22 @@
"Josiah Sprague <josiah.sprague@gmail.com>",
"Sylvan Swierkosz <sswierkosz@gmail.com>"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"files": [
"index.js"
],
"dependencies": {
"automated-readability": "^1.0.0",
"coleman-liau": "^1.0.0",
"dale-chall": "^1.0.0",
"dale-chall": "^2.0.0",
"dale-chall-formula": "^1.0.0",
"flesch": "^1.0.0",
"gunning-fog": "^1.0.0",
"nlcst-to-string": "^2.0.0",
"smog-formula": "^1.0.0",
"spache": "^1.1.0",
"spache": "^2.0.0",
"spache-formula": "^1.0.0",
"syllable": "^4.0.0",
"unist-util-visit": "^2.0.0"
Expand All @@ -62,7 +65,7 @@
"remark-preset-wooorm": "^8.0.0",
"retext": "^7.0.0",
"tape": "^5.0.0",
"xo": "^0.37.0"
"xo": "^0.39.0"
},
"scripts": {
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
Expand All @@ -80,8 +83,9 @@
},
"xo": {
"prettier": true,
"esnext": false,
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off",
"unicorn/no-array-callback-reference": "off",
"unicorn/prefer-includes": "off"
}
Expand Down
8 changes: 3 additions & 5 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'

var test = require('tape')
var retext = require('retext')
var readability = require('.')
import test from 'tape'
import retext from 'retext'
import readability from './index.js'

test('readability', function (t) {
retext()
Expand Down

0 comments on commit ab70516

Please sign in to comment.