strip-json-comments
Advanced tools
Comparing version 1.0.4 to 2.0.0
{ | ||
"name": "strip-json-comments", | ||
"version": "1.0.4", | ||
"version": "2.0.0", | ||
"description": "Strip comments from JSON. Lets you use comments in your JSON files!", | ||
"license": "MIT", | ||
"repository": "sindresorhus/strip-json-comments", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
@@ -20,28 +36,8 @@ "json", | ||
"env", | ||
"environment", | ||
"cli", | ||
"bin" | ||
"environment" | ||
], | ||
"license": "MIT", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"files": [ | ||
"cli.js", | ||
"strip-json-comments.js" | ||
], | ||
"main": "strip-json-comments", | ||
"bin": "cli.js", | ||
"repository": "sindresorhus/strip-json-comments", | ||
"scripts": { | ||
"test": "mocha --ui tdd" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
}, | ||
"engines": { | ||
"node": ">=0.8.0" | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
@@ -14,30 +14,19 @@ # strip-json-comments [![Build Status](https://travis-ci.org/sindresorhus/strip-json-comments.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-json-comments) | ||
It will remove single-line comments `//` and multi-line comments `/**/`. | ||
It will replace single-line comments `//` and multi-line comments `/**/` with whitespace. This allows JSON error positions to remain as close as possible to the original source. | ||
Also available as a [gulp](https://github.com/sindresorhus/gulp-strip-json-comments)/[grunt](https://github.com/sindresorhus/grunt-strip-json-comments)/[broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin. | ||
- | ||
*There's also [`json-comments`](https://npmjs.org/package/json-comments), but it's only for Node.js, inefficient, bloated as it also minifies, and comes with a `require` hook, which is :(* | ||
## Install | ||
```sh | ||
``` | ||
$ npm install --save strip-json-comments | ||
``` | ||
```sh | ||
$ bower install --save strip-json-comments | ||
``` | ||
```sh | ||
$ component install sindresorhus/strip-json-comments | ||
``` | ||
## Usage | ||
```js | ||
var json = '{/*rainbows*/"unicorn":"cake"}'; | ||
const json = '{/*rainbows*/"unicorn":"cake"}'; | ||
JSON.parse(stripJsonComments(json)); | ||
@@ -50,3 +39,3 @@ //=> {unicorn: 'cake'} | ||
### stripJsonComments(input) | ||
### stripJsonComments(input, [options]) | ||
@@ -59,21 +48,16 @@ #### input | ||
#### options | ||
## CLI | ||
##### whitespace | ||
```sh | ||
$ npm install --global strip-json-comments | ||
``` | ||
Type: `boolean` | ||
Default: `true` | ||
```sh | ||
$ strip-json-comments --help | ||
Replace comments with whitespace instead of stripping them entirely. | ||
strip-json-comments input-file > output-file | ||
# or | ||
strip-json-comments < input-file > output-file | ||
``` | ||
## Related | ||
- [`strip-css-comments`](https://github.com/sindresorhus/strip-css-comments) | ||
- [strip-json-comments-cli](https://github.com/sindresorhus/strip-json-comments-cli) - CLI for this module | ||
- [strip-css-comments](https://github.com/sindresorhus/strip-css-comments) - Strip comments from CSS | ||
@@ -80,0 +64,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
1
5015
2
4
61
65