Socket
Socket
Sign inDemoInstall

dale-chall-formula

Package Overview
Dependencies
0
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.5 to 2.0.0

index.d.ts

51

index.js

@@ -1,6 +0,1 @@

'use strict'
module.exports = daleChall
daleChall.gradeLevel = daleChallGradeLevel
var difficultWordWeight = 0.1579

@@ -20,12 +15,27 @@ var wordWeight = 0.0496

9: [13, 15],
10: [16, Infinity],
NaN: [NaN, NaN]
10: [16, Number.POSITIVE_INFINITY],
NaN: [Number.NaN, Number.NaN]
}
function daleChall(counts) {
/**
* @typedef {Object.<string, number>} DaleChallFormulaCounts
* @property {number} sentence
* @property {number} word
* @property {number} difficultWord
*/
/**
* Given the number of words (`word`), the number of sentences (`sentence`), and the number of unique unfamiliar words in a document (`difficultWord`), returns the score associated with the document.
*
* @param {DaleChallFormulaCounts} counts
* @returns {number}
*/
export function daleChallFormula(counts) {
/** @type {number} */
var percentageOfDifficultWords
/** @type {number} */
var score
if (!counts || !counts.sentence || !counts.word) {
return NaN
return Number.NaN
}

@@ -46,13 +56,20 @@

// Mapping between a dale-chall score and a U.S. grade level.
function daleChallGradeLevel(score) {
score = Math.floor(score)
/**
* Mapping between a dale-chall score and a U.S. grade level.
*
* @param {number} score
* @returns {[number, number]}
*/
export function daleChallGradeLevel(score) {
var floored = Math.floor(score)
if (score < 5) {
score = 4
} else if (score > 9) {
score = 10
if (floored < 5) {
floored = 4
} else if (floored > 9) {
floored = 10
}
return gradeMap[score].concat()
// eslint-ignore-next-line capitalized-comments
// type-coverage:ignore-next-line
return gradeMap[floored].concat()
}
{
"name": "dale-chall-formula",
"version": "1.0.5",
"version": "2.0.0",
"description": "Formula to detect the grade level of text according to the (revised) Dale-Chall Readability Formula (1995)",

@@ -22,32 +22,30 @@ "license": "MIT",

],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts",
"index.js"
],
"dependencies": {},
"devDependencies": {
"browserify": "^16.0.0",
"is-nan": "^1.0.0",
"nyc": "^15.0.0",
"prettier": "^1.0.0",
"remark-cli": "^7.0.0",
"remark-preset-wooorm": "^6.0.0",
"tape": "^4.0.0",
"tinyify": "^2.0.0",
"xo": "^0.25.0"
"@types/tape": "^4.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"rimraf": "^3.0.0",
"tape": "^5.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.38.0"
},
"scripts": {
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
"build-bundle": "browserify . -s daleChallFormula -o dale-chall-formula.js",
"build-mangle": "browserify . -s daleChallFormula -p tinyify -o dale-chall-formula.min.js",
"build": "npm run build-bundle && npm run build-mangle",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run format && npm run build && npm run test-coverage"
"prepack": "npm run build && npm run format",
"build": "rimraf \"*.d.ts\" && tsc && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node test.js",
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js",
"test": "npm run build && npm run format && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {

@@ -63,6 +61,6 @@ "tabWidth": 2,

"prettier": true,
"esnext": false,
"ignores": [
"dale-chall-formula.js"
]
"rules": {
"no-var": "off",
"prefer-arrow-callback": "off"
}
},

@@ -73,3 +71,8 @@ "remarkConfig": {

]
},
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true
}
}

@@ -15,2 +15,5 @@ # dale-chall-formula

This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
instead of `require`d.
[npm][]:

@@ -25,3 +28,3 @@

```js
var daleChallFormula = require('dale-chall-formula')
import {daleChallFormula, daleChallGradeLevel} from 'dale-chall-formula'

@@ -34,3 +37,3 @@ daleChallFormula({word: 30, sentence: 2, difficultWord: 6}) // => 4.41208

daleChallFormula.gradeLevel(daleChallFormula(30, 2, 6)) // => [9, 10]
daleChallGradeLevel(daleChallFormula(30, 2, 6)) // => [9, 10]
```

@@ -40,2 +43,6 @@

This package exports the following identifiers: `daleChallFormula`,
`daleChallGradeLevel`.
There is no default export.
### `daleChallFormula(counts)`

@@ -47,3 +54,3 @@

### `daleChallFormula.gradeLevel(score)`
### `daleChallGradeLevel(score)`

@@ -85,5 +92,5 @@ Given a score, returns the corresponding grade ranges

[build-badge]: https://img.shields.io/travis/words/dale-chall-formula.svg
[build-badge]: https://github.com/words/dale-chall-formula/workflows/main/badge.svg
[build]: https://travis-ci.org/words/dale-chall-formula
[build]: https://github.com/words/dale-chall-formula/actions

@@ -90,0 +97,0 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/words/dale-chall-formula.svg

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc