Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/filiptammergard/text-analyzer
Utility functions providing possibilities to analyze text.
https://github.com/filiptammergard/text-analyzer
characters reading-time text time words
Last synced: 25 days ago
JSON representation
Utility functions providing possibilities to analyze text.
- Host: GitHub
- URL: https://github.com/filiptammergard/text-analyzer
- Owner: filiptammergard
- License: mit
- Created: 2021-04-14T17:35:37.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-07T17:30:38.000Z (about 1 month ago)
- Last Synced: 2024-10-12T09:32:14.985Z (26 days ago)
- Topics: characters, reading-time, text, time, words
- Language: TypeScript
- Homepage:
- Size: 1.18 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# text-analyzer
Utility functions providing possibilities to analyze text.
## Installation
Install this package:
```bash
# npm
npm install text-analyzer# yarn
yarn add text-analyzer# pnpm
pnpm add text-analyzer
```## Usage
```js
import {
countCharacters,
countWords,
countSequences,
getReadingTime,
} from "text-analyzer"const text =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."const characters = countCharacters(text)
// characters = 445const words = countWords(text)
// words = 69const sequences = countSequences(text, "dolor")
// default case sensitivity is set to "insensitive"
// sequences = 4const caseInsensitiveSequences = countSequences(text, "lorem", {
caseSensitivity: "insensitive",
})
// caseSensitiveSequences = 1const caseSensitiveSequences = countSequences(text, "lorem", {
caseSensitivity: "sensitive",
})
// caseSensitiveSequences = 0const readingTime = getReadingTime(text)
// default reading speed is set to 200 words per minute
/*
readingTime = {
milliseconds: 20700
minutes: 0.345
words: 69
}
*/const customReadingSpeedReadingTime = getReadingTime(text, {
wordsPerMinute: 100,
})
/*
customReadingSpeedReadingTime = {
milliseconds: 41400
minutes: 0.69
words: 69
}
*/
```## Licence
MIT