This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

literal-parser
TypeScript icon, indicating that this package has built-in type declarations

3.0.5 • Public • Published

literal-parser logo

🔎 literal-parser

A small library to parse and serialize JavaScript array/object literal.

This is like a JSON.parse / JSON.serialize but for JavaScript object instead of JSON objects.

Gist

import Parser from 'literal-parser';

Parser.parse('{ some: ["object", { literal: true }] }');
// return an object { some: ["object", { literal: true }] }

Supported features

Take a look at the tests see what is supported.

API

Parser.parse(str)

Parse the string, expect the string to contain only one expression and throw otherwise.

Return the parsed object.

Parser.parseOne(str)

Parse one expression then stop.

Returns a object with { value, length } where value is the parsed expression and length is the number of character parsed.

Parser.parseOne('{ props: true }} something="else" />');
// { value: { props: true }, length: 15 }

Serializer.serialize(obj)

Print an object.

Readme

Keywords

none

Package Sidebar

Install

npm i literal-parser

Weekly Downloads

12

Version

3.0.5

License

MIT

Unpacked Size

24 kB

Total Files

6

Last publish

Collaborators

  • etienne-dldc-graveyard