@masteravodoprovodchiki/casttovania
v0.0.3
Published
Convert string to something
Readme
CastToVania
Cast your string to something another
Maybe to string, maybe to number, maybe to array of numbers!
Also supports booleans
Installation
yarn add @masteravodoprovodchiki/casttovania
# if you use npm
npm i --save @masteravodoprovodchiki/casttovaniaExamples
const cast = require('@masteravodoprovodchiki/casttovania')
const number = cast('1') // will be 1
const number = cast('true') // will be true
const number = cast('TRUE') // will be true
const number = cast('TrUe') // will be true
const number = cast('false') // will be false
const string = cast('foo') // will be 'foo'
const array0 = cast('foo,bar') // will be ['foo', 'bar']
const array1 = cast('foo,1') // will be ['foo', 1]
const array2 = cast('foo,') // will be ['foo']