Skip to content

Commit

Permalink
adding more examples of numbers and how they suck
Browse files Browse the repository at this point in the history
  • Loading branch information
bahamas10 committed Dec 17, 2012
1 parent 776448c commit 69e9813
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
47 changes: 26 additions & 21 deletions README.md
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,27 +23,32 @@ Example
------- -------


``` js ``` js
var autocast = require('autocast'); > var autocast = require('autocast');
var x; [Function: autocast]

> autocast('5')
x = autocast('5') 5
// x => 5 > autocast('5.8')
x = autocast('5.8') 5.8
// x => 5.8 > autocast('5.8.8')
x = autocast('5.8.8') '5.8.8'
// x => '5.8.8' > autocast('null')
x = autocast('null') null
// x => null > autocast('undefined')
x = autocast('undefined') undefined
// x => undefined > autocast('NaN')
x = autocast('NaN') NaN
// x => NaN > autocast('true')
x = autocast('true') true
// x => true > autocast('false')
x = autocast('false') false
// x => false > autocast('normal string')
x = autocast('normal string') 'normal string'
// x => 'normal string' > autocast('0xff')
255
> autocast('1e3')
1000
> autocast('0001')
1
``` ```


Install Install
Expand Down
3 changes: 3 additions & 0 deletions tests/test.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ assert.strictEqual(autocast('5.6.7'), '5.6.7');
assert.strictEqual(autocast('0'), 0); assert.strictEqual(autocast('0'), 0);
assert.strictEqual(typeof autocast('NaN'), 'number'); assert.strictEqual(typeof autocast('NaN'), 'number');
assert.ok(isNaN(autocast('NaN'))); assert.ok(isNaN(autocast('NaN')));
assert.strictEqual(autocast('0xff'), 255);
assert.strictEqual(autocast('1e3'), 1000);
assert.strictEqual(autocast('0001'), 1);
console.log('ok'); console.log('ok');


console.log('Testing common data types...'); console.log('Testing common data types...');
Expand Down

0 comments on commit 69e9813

Please sign in to comment.