3.0.5 • Published 11 months ago

literal-parser v3.0.5

Weekly downloads
17
License
MIT
Repository
github
Last release
11 months ago

🔎 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.

3.0.4

11 months ago

3.0.5

11 months ago

3.0.3

1 year ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.1.3

3 years ago

2.1.2

3 years ago

2.1.1

3 years ago

2.1.0

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-alpha.0

4 years ago