@naturalcycles/js-lib
Version:
Standard library for universal (browser + Node.js) javascript
16 lines (15 loc) • 452 B
TypeScript
/**
* Splits `string` into an array of its words.
*
* @param [s=''] The string to inspect.
* @param [pattern] The pattern to match words.
* @returns Returns the words of `string`.
* @example
*
* words('fred, barney, & pebbles')
* // => ['fred', 'barney', 'pebbles']
*
* words('fred, barney, & pebbles', /[^, ]+/g)
* // => ['fred', 'barney', '&', 'pebbles']
*/
export declare function words(s: string, pattern?: RegExp | string): string[];