Skip to content

Commit

Permalink
Fix Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Hurlburt committed May 25, 2017
1 parent d20309b commit 984dae1
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A simple JavaScript utility to convert various values to a number.

**What it does that `new Number` doesn't**

* Won't return a `Number` instance with convert.
* Won't return a `Number` instance.
* Allow a default value to be set instead of returning `NaN`.
* Convert `'-0'` to `0` instead of `-0`.

Expand All @@ -39,40 +39,40 @@ npm install --save qc-to_num
```js
import { toNum } from 'qc-to_num';

toNum('+3.1459'); // `3.1459`
toNum('2'); // `2`
toNum(2.6); // `2.6`
toNum(1.2); // `1.2`
toNum(1); // `1`
toNum(-1); // `-1`
toNum(-2.6); // `-2.6`
toNum({ valueOf() { return 42; } }); // `42`
toNum({ valueOf() { return '42'; } }); // `42`
toNum('+3.1459'); // `3.1459`
toNum('2'); // `2`
toNum(2.6); // `2.6`
toNum(1.2); // `1.2`
toNum(1); // `1`
toNum(-1); // `-1`
toNum(-2.6); // `-2.6`
toNum({ valueOf() { return 42; } }); // `42`
toNum({ valueOf() { return '42'; } }); // `42`

toNum(<non-convertible>); // The non-convertible input
toNum(<non-convertible>, undefined); // The non-convertible input
toNum(<non-convertible>, { def: undefined }); // The non-convertible input
toNum(<inconvertible>); // The inconvertible input
toNum(<inconvertible>, undefined); // The inconvertible input
toNum(<inconvertible>, { def: undefined }); // The inconvertible input

toNum(&lt;non-convertible>, null); // `null`
toNum(&lt;non-convertible>, { def: null }); // `null`
toNumOrNull(&lt;non-convertible>); // `null`
toNum(<inconvertible>, null); // `null`
toNum(<inconvertible>, { def: null }); // `null`
toNumOrNull(<inconvertible>); // `null`

toNum(&lt;non-convertible>, 0); // `0`
toNum(&lt;non-convertible>, { def: 0 }); // `0`
toNum(<inconvertible>, 0); // `0`
toNum(<inconvertible>, { def: 0 }); // `0`

toNum(&lt;non-convertible>, NaN); // `NaN`
toNum(&lt;non-convertible>, { def: NaN }); // `NaN`
toNum(<inconvertible>, NaN); // `NaN`
toNum(<inconvertible>, { def: NaN }); // `NaN`

toNum(); // `undefined`
toNumOrNull(); // `null`
toNum(); // `undefined`
toNumOrNull(); // `null`

toNum(NaN); // `NaN`
toNum(NaN, null); // `null`
toNumOrNull(NaN); // `null`
toNum(NaN); // `NaN`
toNum(NaN, null); // `null`
toNumOrNull(NaN); // `null`

toNum(''); // `''`
toNum('', null); // `null`
toNumOrNull(''); // `null`
toNum(''); // `''`
toNum('', null); // `null`
toNumOrNull(''); // `null`
```


Expand Down

0 comments on commit 984dae1

Please sign in to comment.