Cast a string (where possible) to a primitive type.
npm install stereotype> Cast a string (where possible) to a primitive type.
``js
stereotype('undefined'); //=> undefined
stereotype('null'); //=> null
stereotype('NaN'); //=> NaN
stereotype('Infinity'); //=> Infinity
stereotype('true'); //=> true
stereotype('3.14'); //=> 3.14
stereotype('0xFF'); //=> 255
stereotype({}); //=> {}
stereotype('foo'); //=> 'foo'
`
More usage examples are in the tests.
Returns, where possible, obj cast to a primitive type. Otherwise returns obj if obj is not a string, or if obj cannot be cast to a primitive.
Install via npm:
`bash``
$ npm i --save stereotype