Simple, opinionated typecasting
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.gitignore
Makefile
component.json
index.js
package.json
readme.md

readme.md

typecast

Simple typecasting in javascript.

Example

var typecast = require('typecast');

typecast(123, 'string') // => '123'
typecast('123', 'number') // => 123
typecast('a, b, c', 'array') // => ['a', 'b', 'c']
typecast('false', 'boolean') // => false

API

typecast(val, type)

Cast given val to type

.string(val)

Cast val to String

.number(val)

Cast val to Number

.array(val)

Cast val to Array

.date(val)

Cast val to Date

.boolean(val)

Cast val to Boolean

Licence

MIT