# random-gen

> random generator

Latest version **0.1.0** (published 2016-02-15) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install random-gen
pnpm add random-gen
yarn add random-gen
bun add random-gen
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-02-15 |
| First published | 2015-11-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Dustin Stiles |
| Maintainers | dustinwstiles |
| Keywords | random |

## Links

- npm: https://www.npmjs.com/package/random-gen
- Repository: https://github.com/dustinws/random-gen
- Homepage: https://github.com/dustinws/random-gen#readme
- Issues: https://github.com/dustinws/random-gen/issues
- npm.io page: https://npm.io/package/random-gen

## Recent versions

- 0.1.0 (latest) — 2016-02-15
- 0.0.3 — 2016-02-15
- 0.0.200 — 2015-11-21
- 0.0.124 — 2015-11-21
- 0.0.123 — 2015-11-21
- 0.0.122 — 2015-11-21
- 0.0.121 — 2015-11-21
- 0.0.12 — 2015-11-21
- 0.0.11 — 2015-11-21
- 0.0.1 — 2015-11-21

## README

# random-gen

Easily create random strings of any length.


*New in v0.1.0*
#### Easily add your own charsets to random with mixins!
---

#### *API*      
`random.number(n)`        
`random.lower(n)`        
`random.upper(n)`        
`random.letters(n)`        
`random.alphaNum(n)`        
`random.any(n)`        
`random.id()`        
`random.mixin(name, charset, [interceptor])`        

`n` represents the desired length of the string, but `random` will use 8 by default if you choose not to pass anything.         



#### *DOCS*       
---
`random.number(n)`      

Returns an integer of `n` length
```JavaScript
random.number(16)
//=> "7753750611098561"
```
---
`random.lower(n)`      

Returns a lowercase string of `n` length
```JavaScript
random.lower(16)
//=> "mcgjmlihofwxjfsx"
```
---
`random.upper(n)`      

Returns an uppercase string of `n` length
```JavaScript
random.upper(16)
//=> "TKTTVSDZYEGBVMMV"
```
---
`random.letters(n)`      

Returns an upper / lower case string of `n` length
```JavaScript
random.letters(16)
//=> "ahWfDPoyOrVSaKYg"
```
---
`random.alphaNum(n)`      

Returns an alpha-numeric string of `n` length
```JavaScript
random.alphaNum(16)
//=> "lEJYcbYznCU5ORdj"
```
---
`random.any(n)`      

Same as `random.alphaNum` with the addition of the `$ and !` characters
```JavaScript
random.any(16)
//=> "f$KgcADOIrEyxE!o"
```
---
`random.id()`      

A convenient shorthand for calling `random.any(16)`
```JavaScript
random.id()
//=> "f$KgcADOIrEyxE!o"
```
---
`random.mixin(name, charsets, [interceptor])`      

Extend `random` with your own charsets. Pass an optional interceptor to manipulate the result before returning to the client.          
*NOTE* If you pass an interceptor, you MUST return the result when you are done
```JavaScript
var foos = 'foobarbazbing'.split('');
random.mixin('foo', foos);
// Now foo is a property on the `random` object,
// and behaves the same as the rest of the API,
// accepting the length of the result,
// or defaulting to 8.
random.foo(1) //=> 'o'
random.foo(3) //=> 'orb'
random.foo(16) //=> 'fzgngorbzbbooorn'
```
If you would like to change the result before it's returned to the client, pass an interceptor function. This function accepts the result, and must RETURN SOMETHING.
```JavaScript
var foos = 'foobarbazbing'.split('');
random.mixin('foo', foos, function(result) {
  return result.toUpperCase();
});

random.foo() //=> 'ABRBBOZO'
```

---
_Source: https://npm.io/package/random-gen · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
