<commit_before># just-numbers 

[![Build Status](https://travis-ci.org/radiovisual/just-numbers.svg?branch=master)](https://travis-ci.org/radiovisual/just-numbers)

> Remove all non-number characters and return a number. `'$1,234'` → `1234`

This module will also attempt to preserve your decimal precision using the [float option](https://github.com/radiovisual/just-numbers#float): `'$1,234.12'` → `1234.12`

## Install

```
$ npm install --save just-numbers
```


## Usage

```js
const justNumbers = require('just-numbers');

justNumbers('$1,234.00');
//=> 123400

justNumbers('$1$2$3$4$5');
//=> 12345

justNumbers('no-numbers-in-string');
//=> 0

justNumbers('$1,234.23', {float: true});
//=> 1234.23
```

## v1.0

The `0.x` version of this module would simply return `0` (zero) when no numbers were found in the string.
 This behavior has changed in `v1.0`, and now `undefined` is returned when no numbers are found in the string.
 If you want to mimic the behavior of `0.x`, you can tell just-numbers to return zero on empty with the [zeroOnEmpty](https://github.com/radiovisual/just-numbers#zeroonempty) option.

Version 1.0 also allows you to supply your own return value in the event of an empty string using the [onNull](https://github.com/radiovisual/just-numbers#onNull) option.

## API

### just-numbers(input, [options])

Returns a `number`, `undefined` or a [custom value](https://github.com/radiovisual/just-numbers#onNull).

#### input

Type: `string`

The string containing numbers.

#### options

##### float

Type: `boolean`    
Default: `false`

Turns on the attempt to preserve your decimal precision in strings.

```js
justNumbers('$123,456,789.02', {float: true});
//=> 123456789.02
```

##### zeroOnEmpty

Type: `boolean`    <commit_msg>fix onnull link<commit_after># just-numbers 

[![Build Status](https://travis-ci.org/radiovisual/just-numbers.svg?branch=master)](https://travis-ci.org/radiovisual/just-numbers)

> Remove all non-number characters and return a number. `'$1,234'` → `1234`

This module will also attempt to preserve your decimal precision using the [float option](https://github.com/radiovisual/just-numbers#float): `'$1,234.12'` → `1234.12`

## Install

```
$ npm install --save just-numbers
```


## Usage

```js
const justNumbers = require('just-numbers');

justNumbers('$1,234.00');
//=> 123400

justNumbers('$1$2$3$4$5');
//=> 12345

justNumbers('no-numbers-in-string');
//=> 0

justNumbers('$1,234.23', {float: true});
//=> 1234.23
```

## v1.0

The `0.x` version of this module would simply return `0` (zero) when no numbers were found in the string.
 This behavior has changed in `v1.0`, and now `undefined` is returned when no numbers are found in the string.
 If you want to mimic the behavior of `0.x`, you can tell just-numbers to return zero on empty with the [zeroOnEmpty](https://github.com/radiovisual/just-numbers#zeroonempty) option.

Version 1.0 also allows you to supply your own return value in the event of an empty string using the [onNull](https://github.com/radiovisual/just-numbers#onnull) option.

## API

### just-numbers(input, [options])

Returns a `number`, `undefined` or a [custom value](https://github.com/radiovisual/just-numbers#onnull).

#### input

Type: `string`

The string containing numbers.

#### options

##### float

Type: `boolean`    
Default: `false`

Turns on the attempt to preserve your decimal precision in strings.

```js
justNumbers('$123,456,789.02', {float: true});
//=> 123456789.02
```

##### zeroOnEmpty

Type: `boolean`    
{'fraction_non_alphanumeric': 0.1621315192743764, 'fraction_numerical': 0.048752834467120185, 'mean_word_length': 4.540031397174254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 12, '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': '2693733', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1165, 'n_words': 358}