Cast values to a specific type


License
MIT
Install
npm install sc-cast@0.0.7

Documentation

TOC

sc-cast

Cast values to specific types.

cast( "[1,2,3]", "array" ).should.eql( [ 1, 2, 3 ] );
cast( "false", "boolean" ).should.eql( false );
cast( "29 aug 1997", "date" ).should.eql( new Date( 1997, 7, 29 ) );
cast( "-42", "number" ).should.eql( -42 );
cast( true, "string" ).should.eql( "true" );