<commit_before># nodeON-helpers

> A Collection of helper methods.

[![Build Status](https://secure.travis-ci.org/thanpolas/nodeOn-helpers.png?branch=master)](http://travis-ci.org/thanpolas/nodeOn-helpers)

## Install

Install the module using NPM:

```
npm install nodeon-helpers --save
```

## <a name='TOC'>Table of Contents</a>

1. [API](#api)
    1. [Set a salt string](#setSalt)
    1. [Generate a random string](#generateRandomString)
    1. [Generate a random number](#generateRandomNumber)
    1. [Hash a string using bcrypt](#hash)
    1. [Verify a hashed string match](#hashVerify)
    1. [Get a url safe string](#urlify)
    1. [Truncate arguments from a function](#truncateArgs)
    1. [Will copy an array over an existing one](#pushCopy)
    1. [Get the current user HOME dir](#getUserHome)
    1. [Determine if a value is numeric](#isNumeric)

## API

### <a name='setSalt'>Set a salt string</a>

> ### helpers.setSalt(salt)
>
>    * **salt** `string` Any string.

Use it once to set a salt for the crypto functions.

**[[⬆]](#TOC)**

### <a name='generateRandomString'>Generate a random string</a>

> ### helpers.generateRandomString(optLength)
>
>    * **optLength** `number=` Define length, default 32.
>
> *Returns* `string` The random string.

Returns a randomized string.

**[[⬆]](#TOC)**


### <a name='generateRandomNumber'>Generate a random number</a>

> ### helpers.generateRandomNumber(optLength)
>
>    * **optLength** `number=` Define length, default 20.
>
> *Returns* `string` The random string of numbers.

Returns a randomized string only with numbers.

**[[⬆]](#TOC)**


### <a name='hash'>Hash a string using bcrypt</a>

> ### helpers.hash(text, done)
>
>    * **text** `string` The string to hash.
>    * **done** `Function()` Node.js style callback.
>

Hashes a string using the [bcrypt library](https://github.com/ncb000gt/node.bcrypt.js/).

**[[⬆]](#TOC)**


### <a name='hashVerify'>Verify a hashed string match</a>

> ### helpers.hashVerify(hash, text, done)
>
>    * **hash** `string` The hashed string.
>    * **text** `string` The string to test.
>    * **done** `Function(boolean)` Callback with a single argument, boolean.
>

Tests if the given string matches the provided hash.

**[[⬆]](#TOC)**


### <a name='urlify'>Get a url safe string</a>

> ### helpers.urlify(text, optRandLen)
>
>    * **text** `string` The string to urlify.
>    * **optRandLen** `number` How many numbers to use for randomizing the url, default 6.

Get a url safe string.

```js
var helpers = require('nodeon-helpers');

var urlString = helpers.urlify('a name with spaces');

console.log(urlString);
// prints: "458202-a-name-with-spaces"
```

**[[⬆]](#TOC)**

### <a name='truncateArgs'>Truncate arguments from a function</a>

> ### helpers.truncateArgs(fn, count, optSelf)
>
>    * **fn** `Function` The function to truncate arguments.
>    * **count** `number` How many arguments to allow before truncating.
>    * **optSelf** `Object=` Optionally apply context.
>
> *Return* `Function` The function to invoke.

Will truncate arguments from a function.

```js
var helpers = require('nodeon-helpers');

function run(one, two, three) {
    console.log(one); // prints 1
    console.log(two); // prints "undefined"
    console.log(three); // prints "undefined"
}

var fn = helpers.truncateArgs(run, 1);

fn(1, 2, 3);
```

**[[⬆]](#TOC)**

### <a name='pushCopy'>Will copy an array over an existing one</a>

> ### helpers.pushCopy(src, dst)
>
>    * **src** `Array` The source array.
>    * **dst** `Array` The destination array.
>

Will copy an array over an existing one.

```js
var helpers = require('nodeon-helpers');

var src = [4,5,6];
var dst = [1,2,3];

helpers.pushCopy(src, dst);

console.log(dst);
// prints: [1, 2, 3, 4, 5, 6]
```

**[[⬆]](#TOC)**

### <a name='getUserHome'>Get the current user HOME dir.</a>

> ### helpers.getUserHome()
>
> *Return* `string` The full path to the user's HOME.

Get the user's HOME directory.

**[[⬆]](#TOC)**

### <a name='isNumeric'>Determine if a value is numeric.</a>

> ### helpers.isNumeric(value)
>
>    * **value** `string|number` The value to check.
>
> *Return* `boolean` If the value is numeric.

**[[⬆]](#TOC)**

## Release History

- **v0.1.1**, *19 Sep 2014*
    - Added `isNumeric()` method.
- **v0.1.0**, *14 Aug 2014*
    - Big Bang

## License

Copyright (c) 2014 <NAME>. Licensed under the MIT license.<commit_msg>update changelog<commit_after># nodeON-helpers

> A Collection of helper methods.

[![Build Status](https://secure.travis-ci.org/thanpolas/nodeOn-helpers.png?branch=master)](http://travis-ci.org/thanpolas/nodeOn-helpers)

## Install

Install the module using NPM:

```
npm install nodeon-helpers --save
```

## <a name='TOC'>Table of Contents</a>

1. [API](#api)
    1. [Set a salt string](#setSalt)
    1. [Generate a random string](#generateRandomString)
    1. [Generate a random number](#generateRandomNumber)
    1. [Hash a string using bcrypt](#hash)
    1. [Verify a hashed string match](#hashVerify)
    1. [Get a url safe string](#urlify)
    1. [Truncate arguments from a function](#truncateArgs)
    1. [Will copy an array over an existing one](#pushCopy)
    1. [Get the current user HOME dir](#getUserHome)
    1. [Determine if a value is numeric](#isNumeric)

## API

### <a name='setSalt'>Set a salt string</a>

> ### helpers.setSalt(salt)
>
>    * **salt** `string` Any string.

Use it once to set a salt for the crypto functions.

**[[⬆]](#TOC)**

### <a name='generateRandomString'>Generate a random string</a>

> ### helpers.generateRandomString(optLength)
>
>    * **optLength** `number=` Define length, default 32.
>
> *Returns* `string` The random string.

Returns a randomized string.

**[[⬆]](#TOC)**


### <a name='generateRandomNumber'>Generate a random number</a>

> ### helpers.generateRandomNumber(optLength)
>
>    * **optLength** `number=` Define length, default 20.
>
> *Returns* `string` The random string of numbers.

Returns a randomized string only with numbers.

**[[⬆]](#TOC)**


### <a name='hash'>Hash a string using bcrypt</a>

> ### helpers.hash(text, done)
>
>    * **text** `string` The string to hash.
>    * **done** `Function()` Node.js style callback.
>

Hashes a string using the [bcrypt library](https://github.com/ncb000gt/node.bcrypt.js/).

**[[⬆]](#TOC)**


### <a name='hashVerify'>Verify a hashed string match</a>

> ### helpers.hashVerify(hash, text, done)
>
>    * **hash** `string` The hashed string.
>    * **text** `string` The string to test.
>    * **done** `Function(boolean)` Callback with a single argument, boolean.
>

Tests if the given string matches the provided hash.

**[[⬆]](#TOC)**


### <a name='urlify'>Get a url safe string</a>

> ### helpers.urlify(text, optRandLen)
>
>    * **text** `string` The string to urlify.
>    * **optRandLen** `number` How many numbers to use for randomizing the url, default 6.

Get a url safe string.

```js
var helpers = require('nodeon-helpers');

var urlString = helpers.urlify('a name with spaces');

console.log(urlString);
// prints: "458202-a-name-with-spaces"
```

**[[⬆]](#TOC)**

### <a name='truncateArgs'>Truncate arguments from a function</a>

> ### helpers.truncateArgs(fn, count, optSelf)
>
>    * **fn** `Function` The function to truncate arguments.
>    * **count** `number` How many arguments to allow before truncating.
>    * **optSelf** `Object=` Optionally apply context.
>
> *Return* `Function` The function to invoke.

Will truncate arguments from a function.

```js
var helpers = require('nodeon-helpers');

function run(one, two, three) {
    console.log(one); // prints 1
    console.log(two); // prints "undefined"
    console.log(three); // prints "undefined"
}

var fn = helpers.truncateArgs(run, 1);

fn(1, 2, 3);
```

**[[⬆]](#TOC)**

### <a name='pushCopy'>Will copy an array over an existing one</a>

> ### helpers.pushCopy(src, dst)
>
>    * **src** `Array` The source array.
>    * **dst** `Array` The destination array.
>

Will copy an array over an existing one.

```js
var helpers = require('nodeon-helpers');

var src = [4,5,6];
var dst = [1,2,3];

helpers.pushCopy(src, dst);

console.log(dst);
// prints: [1, 2, 3, 4, 5, 6]
```

**[[⬆]](#TOC)**

### <a name='getUserHome'>Get the current user HOME dir.</a>

> ### helpers.getUserHome()
>
> *Return* `string` The full path to the user's HOME.

Get the user's HOME directory.

**[[⬆]](#TOC)**

### <a name='isNumeric'>Determine if a value is numeric.</a>

> ### helpers.isNumeric(value)
>
>    * **value** `string|number` The value to check.
>
> *Return* `boolean` If the value is numeric.

**[[⬆]](#TOC)**

## Release History

- **v0.1.2**, *19 Sep 2014*
    - Added `isNumeric()` method.
- **v0.1.0**, *14 Aug 2014*
    - Big Bang

## License

Copyright (c) 2014 <NAME>. Licensed under the MIT license.
{'fraction_non_alphanumeric': 0.18838768321781615, 'fraction_numerical': 0.01454380184069992, 'mean_word_length': 4.035469107551488, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 147, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5573416', 'n_tokens_mistral': 3245, 'n_tokens_neox': 3092, 'n_words': 914}