1. js-type-escape
escape value to string with type
js-type-escape
Package: js-type-escape
Created by: teeeemoji
Last modified: Fri, 06 May 2022 19:42:12 GMT
Version: 1.0.1
License: MIT
Downloads: 8
Repository: https://github.com/teeeemoji/js-type-escape

Install

npm install js-type-escape
yarn add js-type-escape

js-type-escape

Travis (.com)
Codecov
npm
npm
npm bundle size
GitHub last commit
NPM

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.

 import {processValue2EscapeStr} from 'js-type-escape'
processValue2EscapeStr('js-type-escape') // 1__js-type-escape
processValue2EscapeStr(1000) // 2__1000
processValue2EscapeStr([1,2,3,'4','a']) // 3__[1,2,3,'4','a']
processValue2EscapeStr({a: 1, b: 'c', d: [2, 'e'], f: {g: 'h'}}) // 3__"{"a":1,"b":"c","d":[2,"e"],"f":{"g":"h"}}"
processValue2EscapeStr(true) // 5__true

API

processEscapeStr2Value

src/index.js:15-21

process escape string to value with its data type

Parameters

  • str {string}

Returns (string | any | undefined | number)

processValue2EscapeStr

src/index.js:63-78

process value to escape string

Parameters

  • val {any}

Returns string

License

This project is licensed under the MIT license.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code