autocast

0.0.4 • Public • Published

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');
var x;
 
= autocast('5')
// x => 5
= autocast('5.8')
// x => 5.8
= autocast('5.8.8')
// x => '5.8.8'
= autocast('null')
// x => null
= autocast('undefined')
// x => undefined
= autocast('NaN')
// x => NaN
= autocast('true')
// x => true
= autocast('false')
// x => false
= autocast('normal string')
// x => 'normal string'

Install

npm install autocast

Tests

npm test

License

MIT Licensed

Readme

Keywords

none

Package Sidebar

Install

npm i autocast

Weekly Downloads

1,511

Version

0.0.4

License

none

Last publish

Collaborators

  • bahamas10