@toolsnap/text-counter
v1.0.0
Published
Fast text statistics utility — word count, character count, line count, sentence count and more. Zero dependencies.
Maintainers
Readme
@toolsnap/text-counter
A fast, zero-dependency text statistics utility for Node.js and browsers.
Installation
npm install @toolsnap/text-counterUsage
const { count, wordCount, charCount } = require('@toolsnap/text-counter');
const text = 'Hello world!\nThis is a test.';
const stats = count(text);
// {
// characters: 28,
// charactersNoSpaces: 24,
// words: 6,
// lines: 2,
// sentences: 2,
// paragraphs: 1
// }
wordCount(text); // 6
charCount(text); // 28
charCount(text, true); // 24 (no spaces)Online Tool
Need a quick count without code? Try the free online Text Counter — paste and count instantly.
API
| Function | Parameters | Returns |
|---|---|---|
| count(text) | string | { characters, charactersNoSpaces, words, lines, sentences, paragraphs } |
| wordCount(text) | string | number |
| charCount(text, noSpaces?) | string, boolean | number |
License
MIT
