Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

flesch

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flesch - npm Package Compare versions

Comparing version
1.0.5
to
2.0.0
+32
index.d.ts
/**
* @typedef {Object.<string, number>} FleschCounts
* @property {number} sentence
* @property {number} word
* @property {number} syllable
*/
/**
* Given an object containing the number of words (`word`), the number of sentences (`sentence`), and the number of syllables (`syllable`) in a document, returns the reading ease associated with the document.
*
* Returned values are 120 (every sentence consisting of only two one-syllable words), or lower (including negative values).
*
* The values have the following semantics:
*
* | Score | Semantics |
* | :----------: | :-------------------------------------------------- |
* | 90.0 – 100.0 | Easily understood by an average 11-year-old student |
* | 60.0 – 70.0 | Easily understood by 13- to 15-year-old students |
* | 0.0 – 30.0 | Best understood by university graduates |
*
* Therefore we can use the following formula to approximate the average age a student would understand a document at, given score `score`:
*
* ```js
* var age = 20 - Math.floor(score / 10)
* ```
*
* @param {FleschCounts} counts
* @returns {number}
*/
export function flesch(counts: FleschCounts): number
export type FleschCounts = {
[x: string]: number
}
+31
-6

@@ -1,5 +0,1 @@

'use strict'
module.exports = flesch
var sentenceWeight = 1.015

@@ -9,5 +5,34 @@ var wordWeight = 84.6

function flesch(counts) {
/**
* @typedef {Object.<string, number>} FleschCounts
* @property {number} sentence
* @property {number} word
* @property {number} syllable
*/
/**
* Given an object containing the number of words (`word`), the number of sentences (`sentence`), and the number of syllables (`syllable`) in a document, returns the reading ease associated with the document.
*
* Returned values are 120 (every sentence consisting of only two one-syllable words), or lower (including negative values).
*
* The values have the following semantics:
*
* | Score | Semantics |
* | :----------: | :-------------------------------------------------- |
* | 90.0 – 100.0 | Easily understood by an average 11-year-old student |
* | 60.0 – 70.0 | Easily understood by 13- to 15-year-old students |
* | 0.0 – 30.0 | Best understood by university graduates |
*
* Therefore we can use the following formula to approximate the average age a student would understand a document at, given score `score`:
*
* ```js
* var age = 20 - Math.floor(score / 10)
* ```
*
* @param {FleschCounts} counts
* @returns {number}
*/
export function flesch(counts) {
if (!counts || !counts.sentence || !counts.word || !counts.syllable) {
return NaN
return Number.NaN
}

@@ -14,0 +39,0 @@

+31
-28
{
"name": "flesch",
"version": "1.0.5",
"version": "2.0.0",
"description": "Formula to detect the ease of reading a text according to Flesch Reading Ease (1975)",

@@ -21,32 +21,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 flesch -o flesch.js",
"build-mangle": "browserify . -s flesch -p tinyify -o flesch.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 format && npm run test-coverage"
},
"nyc": {
"check-coverage": true,
"lines": 100,
"functions": 100,
"branches": 100
},
"prettier": {

@@ -62,6 +60,6 @@ "tabWidth": 2,

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

@@ -72,3 +70,8 @@ "remarkConfig": {

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

@@ -15,2 +15,5 @@ # flesch

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 flesch = require('flesch')
import {flesch} from 'flesch'

@@ -38,2 +41,5 @@ // For “The cat sat on the mat” (1 sentence, 6 words, 6 syllables).

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

@@ -86,5 +92,5 @@

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

@@ -91,0 +97,0 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/words/flesch.svg