Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Apr 30, 2019
1 parent 9e6602c commit 119114f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ It will replace single-line comments `//` and multi-line comments `/**\/` with w
@example
```
const json = `{
// rainbows
// Rainbows
"unicorn": "cake"
}`;
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ module.exports = (jsonString, options = {}) => {
}
}

return result + (insideComment ? strip(jsonString.substr(offset)) : jsonString.substr(offset));
return result + (insideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@
"node": ">=8"
},
"scripts": {
"test": "xo && ava",
"test": "xo && ava && tsd",
"bench": "matcha benchmark.js"
},
"files": [
"index.js"
"index.js",
"index.d.ts"
],
"keywords": [
"json",
"strip",
"comments",
"remove",
"delete",
"trim",
"comments",
"multiline",
"parse",
"config",
"configuration",
"conf",
"settings",
"util",
"env",
Expand Down
8 changes: 5 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ This is now possible:

```js
{
// rainbows
// Rainbows
"unicorn": /**/ "cake"
}
```

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


## Install
Expand All @@ -27,7 +27,7 @@ $ npm install strip-json-comments

```js
const json = `{
// rainbows
// Rainbows
"unicorn": /* ❤ */ "cake"
}`;

Expand All @@ -48,6 +48,8 @@ Accepts a string with JSON and returns a string without comments.

#### options

Type: `object`

##### whitespace

Type: `boolean`<br>
Expand Down

0 comments on commit 119114f

Please sign in to comment.