package
Tiny type casting library for node.js and the browser.
npm install castingGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Tiny type casting library for node.js and the browser.
Via npm:
npm install --save castingor bower:
bower install --save castingvar casting = require('casting');
casting.cast(Array, 123); // [123]
casting.cast(String, 123); // '123'
casting.cast(Date, '2014-01-01'); // [object Date]
function MyType (value) {
this.name = value.name;
this.isActive = value.isActive;
}
casting.define('mytype', MyType);
casting.cast('mytype', {name: 'name', isActive: true}); // [object MyType]
var castAll =
First, npm install, then npm test. Code coverage generated with npm run coverage.
MIT, see LICENSE.md.