@zerodep/string-words
TypeScript icon, indicating that this package has built-in type declarations

2.0.11 • Public • Published

@zerodep/string-words

version language types license

CodeFactor Known Vulnerabilities

A utility to split a sentence of words into an array of those words and remove punctuation. Non-string values will cause a ZeroDepError to be thrown.

Full documentation is available at the zerodep.app page.

Examples

All @zerodep packages support both ESM and CJS.

import { stringWords } from '@zerodep/string-words';
// or
const { stringWords } = require('@zerodep/string-words');

Using Default Space Separator

stringWords('California'); // ["California"]
stringWords('3.14 Pi'); // ["3.14", "Pi"]
stringWords("I'll be there for you. How about you?"); // ["I'll", "be", "there", "for", "you", "How", "about", "you"]
stringWords(''); // []

Using Custom Separator

stringWords('this_is_a_snake_case_string', '_'); // ["this", "is", "a", "snake", "case", "string"]

Unsuccessful Response

stringWords({ not: 'a string' }); // throws ZeroDepError: Value is not a string

Readme

Keywords

Package Sidebar

Install

npm i @zerodep/string-words

Homepage

zerodep.app

Weekly Downloads

1

Version

2.0.11

License

MIT

Unpacked Size

7.82 kB

Total Files

8

Last publish

Collaborators

  • cdepage