mirror of
https://github.com/nodejs/node.git
synced 2025-05-18 14:54:35 +00:00

PR-URL: https://github.com/nodejs/node/pull/19560 Fixes: https://github.com/nodejs/node/issues/19271 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com>
54 lines
2.4 KiB
Markdown
54 lines
2.4 KiB
Markdown
# json-parse-better-errors [](https://npm.im/json-parse-better-errors) [](https://npm.im/json-parse-better-errors) [](https://travis-ci.org/zkat/json-parse-better-errors) [](https://ci.appveyor.com/project/zkat/json-parse-better-errors) [](https://coveralls.io/github/zkat/json-parse-better-errors?branch=latest)
|
|
|
|
[`json-parse-better-errors`](https://github.com/zkat/json-parse-better-errors) is a Node.js library for managing
|
|
local key and content address caches. It's really fast, really good at
|
|
concurrency, and it will never give you corrupted data, even if cache files
|
|
get corrupted or manipulated.
|
|
|
|
It was originally written to be used as [npm](https://npm.im)'s local cache, but
|
|
can just as easily be used on its own
|
|
|
|
_Translations: [español](README.es.md)_
|
|
|
|
## Install
|
|
|
|
`$ npm install --save json-parse-better-errors`
|
|
|
|
## Table of Contents
|
|
|
|
* [Example](#example)
|
|
* [Features](#features)
|
|
* [Contributing](#contributing)
|
|
* [API](#api)
|
|
* [`parse`](#parse)
|
|
|
|
### Example
|
|
|
|
```javascript
|
|
const parseJson = require('json-parse-better-errors')
|
|
|
|
parseJson('"foo"')
|
|
parseJson('garbage') // more useful error message
|
|
```
|
|
|
|
### Features
|
|
|
|
* Like JSON.parse, but the errors are better.
|
|
|
|
### Contributing
|
|
|
|
The json-parse-better-errors team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The [Contributor Guide](CONTRIBUTING.md) has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.
|
|
|
|
All participants and maintainers in this project are expected to follow [Code of Conduct](CODE_OF_CONDUCT.md), and just generally be excellent to each other.
|
|
|
|
Please refer to the [Changelog](CHANGELOG.md) for project history details, too.
|
|
|
|
Happy hacking!
|
|
|
|
### API
|
|
|
|
#### <a name="parse"></a> `> parse(txt, ?reviver, ?context=20)`
|
|
|
|
Works just like `JSON.parse`, but will include a bit more information when an
|
|
error happens.
|