A small module that allows you to do simple type casting and detecting.
npm i --save typer
Usage is pretty simple. First, require typer and then use one of the documented methods.
Detect the type of value.
vartyper=require('typer');console.log(typer.detect('12345.12'));// floatconsole.log(typer.detect('12345'));// integerconsole.log(typer.detect('false'));// booleanconsole.log(typer.detect('2016-02-22T18:00:00.000Z'));// datetimeYou can find more examples in the tests.
Cast value to type.
vartyper=require('typer');console.log(typer.cast(23,'string'));// '23'console.log(typer.cast('23','integer'));// 23console.log(typer.cast('23','float'));// 23.00console.log(typer.cast('2016-02-22T18:00:00.000Z','date'));// Mon, 22 Feb 2016 18:00:00 GMT