extw
v1.2.1
Published
Extract words from a given string.
Downloads
33
Maintainers
Readme
extw
Tiny utility that extracts words from a given string and caches parsed result lists.
Usage
const words = require('extw')
words(' Buggy/is, my :beautiful&cat.') // [ 'Buggy', 'is', 'my', 'beautiful', 'cat' ]
API
const extw = require('extw')
typeof extw === 'function'
extw('string') // returns a string array
extw([ 'array' ]) // returns the given array untouched
extw(null) // returns an empty array
extw(true) // raises an assert.AssertionError
extw('string', null) // disable cache for _this_ call
extw('string', {}) // use the given object as cache for _this_ call
typeof extw.cache === 'object'
extw.cache = {} // reset cache
extw.cache = false // disable cache
extw.cache = 'error' // raises an assert.AssertionError
extw.regExp instanceof RegExp === true
extw.regExp = /a+/g // override word match regexp
extw.regExp = 'error' // raises an assert.AssertionError
typeof extw.version === 'string' // returns the version string from package manifest
Installation
With npm:
npm install extw