Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Easily and automatically cast common datatypes in JavaScript
branch: master
Failed to load latest commit information.
tests adding more examples of numbers and how they suck
.gitignore Initial Commit
Makefile Adding support for use on the web
README.md adding more examples of numbers and how they suck
autocast.min.js Adding support for use on the web
index.js Adding support for use on the web
package.json

README.md

autocast

Easily and automatically cast common datatypes in JavaScript

Usage

Node.js

var autocast = require('autocast');

Web

<script src="autocast.min.js"></script>
<!-- // defines autocast() -->

Example

> 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

npm install autocast

Tests

npm test

License

MIT Licensed

Something went wrong with that request. Please try again.