1.0.0 • Published 8 years ago

rndstr v1.0.0

Weekly downloads
1,163
License
MIT
Repository
github
Last release
8 years ago

rndstr.js

Generate random string

Install

$ npm install rndstr --save

Usage

rndstr(opts)

Example

const rndstr = require('rndstr');

rndstr(); // ujvb17u5vxgqsh41mgwhlo3lfjrbz1xy2oi9zgxk7vh04r5p3cfc121fo8bkoj2j
rndstr(); // 9rx8ghughdlihe35l7uzld4f3gvwa0wm0cb21ousiiit7q2uvrixo331zcdkb8kj
rndstr(); // q1a334oio0t6sc5yqb2yjqmuym22acthfzhsnwrr67orp5hvjkj22r9fiehonly9

// === Use custom options ===
rndstr({length: 8, chars: '0-9'}); // 51048708
rndstr({length: 8, chars: '0-9'}); // 80987908
rndstr({length: 8, chars: '0-9'}); // 72556885

// === Specify seed ===
rndstr({seed: 'himawari'}); // Always m8ucpxibnp98qd8791hv98h1knfdypimztyfo3agu7gj757uyicjdea8wwyrpwab
rndstr({seed: 'sakurako'}); // Always kybaq23mek8580s246kjkngupc9zsuyjuqgh6jkbale5btvtzssxjn2g6nienuyq

// === Enable/Disable range-syntax parser ===
rndstr({length: 16, chars: 'a-z', parseRange: true}); // sbywqwriyielxske
rndstr({length: 16, chars: 'a-z', parseRange: false}); // az--a--zaa-a-aa-

Options

PropertyTypeDescriptionDefault
lengthnumberThe length of your resulting string64
charsstring or string[]The chars you want to include'a-z0-9'
seedstring or numberThe seed value to be used to generatenull
parseRangebooleanWhether a given chars be interpreted as a range-syntaxtrue

On TypeScript

Type definition are bundled.

import rndstr from 'rndstr';

License

MIT

1.0.0

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago