Releases: xyfir/rword
Releases · xyfir/rword
4.0.0
V3 to V4 Migration Guide
- Imports:
- Rword now exports an ES Module instead of CommonJS
- Instead of importing a global
rword
instance, import theRword
class and then a separate word list like therword-english-recommended
package
- Instantiation: Create an instance of Rword with the desired word list and optional seed
- API Methods: The methods now belong to an instance and the options object is removed for filtering
Upgrade Steps
-
Import:
- V3
import { rword } from 'rword';
- V4
import { words } from 'rword-english-recommended'; // or 'rword-english-extended' import { Rword } from 'rword'; // Capitalized export
-
Create instance:
- V3: Not needed
- V4
const rword = new Rword(words);
-
Generate words:
- V3
// has filtering options // might return a string, or an array rword.generate(5, { length: '3-10', contains: /pattern/ }); // has generateFromPool method for improved performance rword.generateFromPool(5);
- V4
// only the number of words is accepted // always returns an array // only has a single generate method rword.generate(5);
If you need the old filtering options, you should do this yourself on a words array and then load that new aray into an instance.