sc-cast

v2.0.0
Cast values to a specific type

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" );
npm i sc-cast

Metadata

  • MIT
  • Whatever
  • David Tsuji
  • released 11/25/2015

Downloads