Skip to content
This repository

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

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Makefile
Octocat-spinner-32 README.md
Octocat-spinner-32 autocast.min.js
Octocat-spinner-32 index.js
Octocat-spinner-32 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.