# stray

> The Flexible String Generator

Latest version **0.1.2** (published 2014-10-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install stray
pnpm add stray
yarn add stray
bun add stray
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2014-10-20 |
| First published | 2014-10-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Levi Mootz |
| Maintainers | mootzville |
| Keywords | string, generator |

## Links

- npm: https://www.npmjs.com/package/stray
- Repository: http://github.com/mootzville/strayjs
- Homepage: https://github.com/mootzville/strayjs
- Issues: https://github.com/mootzville/strayjs/issues
- npm.io page: https://npm.io/package/stray

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 0.1.2 (latest) — 2014-10-20
- 0.1.1 — 2014-10-14
- 0.1.0 — 2014-10-13

## README

# StrayJS | The Flexible String Generator

## How it works:


### Simple Example
```
// Bring in the module
var stray = require('stray');

// Create some random strings
// By default, stray will generate
// alphanum strings 10 chars long
// when given no params

var rndStr = stray();
console.log(rndStr); // F8AFmfuDzx
```

### Options Object

StrayJS accepts an options object as it's only argument.

Here are the default settings from the example above:

```
var options = {
  set: 'alnum',
  size: 10,
  insert: null
}
```

### Options Object Params

Here is all you need to know about the params:

set - The 'set' param specifies the string set to use for generating the string.
      
      The built-in sets are:
        alnum = Alphabet (Uppercase & Lowercase) + Numbers (0 to 9)
        num = Numbers (0 to 9)
        alpha = Alphabet (Uppercase & Lowercase)
        bin = Binary (0 and 1)
        hex = Hexadecimal (A to F & 0 to 9)
        dna = DNA Letters (a,c,g,t)
        ascii = All* ascii printable characters (~ 94 Characters)
          * The space (aka ' ') is not included in the ascii set
            though it is considered a printable character.

      You can also specify your own set by simply passing the string set you wish
      to use as the value.  E.G. "set": "!@#$%^&*()"

size - The 'size' param can be either a Number or an Object
      
       As a Number, stray will obviously generate a string of that length.

       Pass an object with 'min' & 'max' params for variable length strings.
       E.G. "size": {"min": 1, "max": 10} // string will be 1 to 10 chars in length

insert - The 'insert' param is an array of objects that specifies
         static characters you want inserted into the string.
         Each object consists of 2 params: 'chars' & 'position'
         The 'chars' is/are the character(s) you want to insert.
         The 'position' is where in the string you want to insert.

         *** The 'insert' param is experimental and may change in the future ***
         *** Don't pass multiple objects with the same 'position' param ***
         *** Well, you can but it may not insert the chars how you'd expect ***

### Generate & Format Some Phone Numbers (USA)
```
var stray = require('strayjs'),
    phone = {
      "set": "num",
      "size": 10,
      "insert": [
        {"chars": '(', "position": 0},
        {"chars": ')', "position": 3},
        {"chars": '-', "position": 6}
      ]
    };

var phoneNum1 = stray(phone),
    phoneNum2 = stray(phone),
    phoneNum3 = stray(phone);

console.log(phoneNum1); // (203)222-8585
console.log(phoneNum2); // (968)676-3774
console.log(phoneNum3); // (412)824-8847
```

Run 'test.js' and check out it's source for a few other examples.

Check out stringSets.js for the built-in sets.  Add to it if you'd like.

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