string-serializer
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

string-serializer

npm version

A JavaScript utility for parsing and stringifying values

Installation

npm install string-serializer

The CDN build is also available on unpkg:

API

  • parseArray()
  • parseObject()
  • parseBoolean()
  • parseInt(): An alias for Number.parseInt()
  • parseFloat(): An alias for Number.parseFloat()
  • stringifyArray()
  • stringifyObject()

Usage

import { parseArray, parseObject } from 'string-serializer';
 
parseArray('[1,2,3]'); // [1, 2, 3]
parseArray('1,2,3'); // [1, 2, 3]
parseArray('"1","2","3"'); // ["1", "2", "3"]
 
parseArray('["a","b","c"]'); // ["a", "b", "c"]
parseArray('[a,b,c]'); // ["a", "b", "c"]
parseArray('a,b,c'); // ["a", "b", "c"]
 
parseObject('{a:1}'); // { a: 1 }
parseObject('{"a":1}'); // { a: 1 }

License

MIT © Qingrong Ke

Package Sidebar

Install

npm i string-serializer

Weekly Downloads

1

Version

1.1.3

License

MIT

Unpacked Size

18.1 kB

Total Files

7

Last publish

Collaborators

  • dearke