typecast

0.0.1 • Public • Published

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

.boolean(val)

Cast val to Boolean

Licence

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.1
    44,392
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.1
    44,392

Package Sidebar

Install

npm i typecast

Weekly Downloads

37,628

Version

0.0.1

License

MIT

Last publish

Collaborators

  • eivifj