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.
All @zerodep packages support both ESM and CJS.
import { stringWords } from '@zerodep/string-words';
// or
const { stringWords } = require('@zerodep/string-words');
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(''); // []
stringWords('this_is_a_snake_case_string', '_'); // ["this", "is", "a", "snake", "case", "string"]
stringWords({ not: 'a string' }); // throws ZeroDepError: Value is not a string