js-type-escape
Convert JS value to escape string, and then you can convert back.
js-type-escape
's main API processValue2EscapeStr
converts Javascript Value to an escape string, and another API processEscapeStr2Value
converts escape string to Javascript Value with correct date type.
Installation
$ npm install js-type-escape
Usage
Important: Only primitive types, Object and Array are supported, function, Date are not supported.
// 1__js-type-escape // 2__1000 // 3__[1,2,3,'4','a'] // 3__"{"a":1,"b":"c","d":[2,"e"],"f":{"g":"h"}}" // 5__true
API
processEscapeStr2Value
process escape string to value with its data type
Parameters
str
{string}
Returns (string | any | undefined | number)
processValue2EscapeStr
process value to escape string
Parameters
val
{any}
Returns string
License
This project is licensed under the MIT license.