comment-json
Advanced tools
+1
-1
| { | ||
| "name": "comment-json", | ||
| "version": "4.4.0", | ||
| "version": "4.4.1", | ||
| "description": "Parse and stringify JSON with comments. It will retain comments even after saved!", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
+2
-2
@@ -606,3 +606,3 @@ [](https://github.com/kaelzhang/node-comment-json/actions/workflows/nodejs.yml) | ||
| `{"foo": 9007199254740993}`, | ||
| // | ||
| // The reviver function now has a 3rd param that contains the string source. | ||
| (key, value, {source}) => | ||
@@ -621,3 +621,3 @@ /^[0-9]+$/.test(source) ? BigInt(source) : value | ||
| // JSON.rawJSON is supported in node >= 21 | ||
| ? JSON.rawJSON(String(val)).rawJSON | ||
| ? JSON.rawJSON(String(val)) | ||
| : value | ||
@@ -624,0 +624,0 @@ ) |
+11
-1
@@ -5,3 +5,4 @@ const { | ||
| isString, | ||
| isNumber | ||
| isNumber, | ||
| isFunction | ||
| } = require('core-util-is') | ||
@@ -128,2 +129,9 @@ | ||
| const is_raw_json = isFunction(JSON.isRawJSON) | ||
| // For backward compatibility, | ||
| // since JSON.isRawJSON is not supported in node < 21 | ||
| ? JSON.isRawJSON | ||
| // istanbul ignore next | ||
| : () => false | ||
| module.exports = { | ||
@@ -159,2 +167,4 @@ SYMBOL_PREFIXES, | ||
| is_raw_json, | ||
| assign (target, source, keys) { | ||
@@ -161,0 +171,0 @@ if (!isObject(target)) { |
+7
-1
@@ -22,3 +22,5 @@ const { | ||
| UNDEFINED | ||
| UNDEFINED, | ||
| is_raw_json | ||
| } = require('./common') | ||
@@ -296,2 +298,6 @@ | ||
| case 'object': | ||
| if (is_raw_json(value)) { | ||
| return value.rawJSON | ||
| } | ||
| return isArray(value) | ||
@@ -298,0 +304,0 @@ ? array_stringify(value, gap) |
48299
0.78%1162
1.04%