Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding more examples of numbers and how they suck

  • Loading branch information...
commit 69e9813fd1434a6ccf736eaf8c8bf312a7a0ca6e 1 parent 776448c
@bahamas10 authored
Showing with 29 additions and 21 deletions.
  1. +26 −21 README.md
  2. +3 −0  tests/test.js
View
47 README.md
@@ -23,27 +23,32 @@ Example
-------
``` js
-var autocast = require('autocast');
-var x;
-
-x = autocast('5')
-// x => 5
-x = autocast('5.8')
-// x => 5.8
-x = autocast('5.8.8')
-// x => '5.8.8'
-x = autocast('null')
-// x => null
-x = autocast('undefined')
-// x => undefined
-x = autocast('NaN')
-// x => NaN
-x = autocast('true')
-// x => true
-x = autocast('false')
-// x => false
-x = autocast('normal string')
-// x => 'normal string'
+> var autocast = require('autocast');
+[Function: autocast]
+> autocast('5')
+5
+> autocast('5.8')
+5.8
+> autocast('5.8.8')
+'5.8.8'
+> autocast('null')
+null
+> autocast('undefined')
+undefined
+> autocast('NaN')
+NaN
+> autocast('true')
+true
+> autocast('false')
+false
+> autocast('normal string')
+'normal string'
+> autocast('0xff')
+255
+> autocast('1e3')
+1000
+> autocast('0001')
+1
```
Install
View
3  tests/test.js
@@ -13,6 +13,9 @@ assert.strictEqual(autocast('5.6.7'), '5.6.7');
assert.strictEqual(autocast('0'), 0);
assert.strictEqual(typeof autocast('NaN'), 'number');
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('Testing common data types...');
Please sign in to comment.
Something went wrong with that request. Please try again.