# js-value-parser

> deserialize javascript objects including non-standard JSON in fragmented text

Latest version **1.0.0** (published 2019-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-value-parser
pnpm add js-value-parser
yarn add js-value-parser
bun add js-value-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2019-12-11 |
| First published | 2019-12-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | kluezesh |
| Maintainers | kluezesh |
| Keywords | json, parse, parser, deserialize, non-standard, static, eval, safe |

## Links

- npm: https://www.npmjs.com/package/js-value-parser
- npm.io page: https://npm.io/package/js-value-parser

## Dependencies (1)

- [acorn](https://npm.io/package/acorn.md) ^7.1.0

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.0 (latest) — 2019-12-11

## README

# js-value-parser
deserialize javascript objects including non-standard JSON in fragmented text

## Installation
```
npm install js-value-parser
```

## Useage

parse(msg, \[offset, \[options]\])

parse(ast, \[options\])

#### example:
```javascript
const {
  parse,
  FILTER_JSONP,
} = require('js-value-parser');

const msg = '... xxx = {a:1} ... ';
console.log(parse(msg, msg.indexOf('=') + 1)); // => { a : 1 }

console.log(parse('jsonpCallback([2])', 0, {filter: FILTER_JSONP})); // => [2]
```

#### options

`context` - the value map of identifier refers, default `CONTEXT_MINIMUM`

`filter` - find the target ast node, default `FILTER_LEFTEST`

`evaluator` - calculate ast's values, default `EVALUATOR_CONSTANT`

## Components
- context
    - `CONTEXT_MINIMUM`: only include `undefined`, `Infinity`, `NaN`

- filter
    - `FILTER_LEFTEST`: find the ast node of object or constant on the left side
    - `FILTER_JSONP`: find the ast node of the first argument of function calling

- evaluator
    - `EVALUATOR_CONSTANT`: turn `!0`,`!1`,`void 0` into `true`,`false`,`undefined`, then statically evaluating constant value (object, array, string, number, boolean, null & refers in context), otherwise throw an error (e.g. invoke function)

---
_Source: https://npm.io/package/js-value-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
