@qubit-ltd/json 1.1.4 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +206 -28
- package/README.zh_CN.md +205 -27
- package/dist/json.cjs +90 -63
- package/dist/json.cjs.map +1 -1
- package/dist/json.min.cjs +1 -1
- package/dist/json.min.cjs.map +1 -1
- package/dist/json.min.mjs +1 -1
- package/dist/json.min.mjs.map +1 -1
- package/dist/json.mjs +90 -63
- package/dist/json.mjs.map +1 -1
- package/doc/api/LosslessNumber.html +1 -1
- package/doc/api/global.html +1 -1
- package/doc/api/index.html +196 -29
- package/doc/json.min.visualization.html +1 -1
- package/doc/json.visualization.html +1 -1
- package/package.json +16 -14
package/doc/api/index.html
CHANGED
|
@@ -54,25 +54,25 @@
|
|
|
54
54
|
<a href="README.zh_CN.md"><img src="https://img.shields.io/badge/%E6%96%87%E6%A1%A3-%E4%B8%AD%E6%96%87%E7%89%88-blue.svg" alt="中文文档"></a>
|
|
55
55
|
<a href="https://dl.circleci.com/status-badge/redirect/gh/Haixing-Hu/js-json/tree/master"><img src="https://dl.circleci.com/status-badge/img/gh/Haixing-Hu/js-json/tree/master.svg?style=shield" alt="CircleCI"></a>
|
|
56
56
|
<a href="https://coveralls.io/github/Haixing-Hu/js-json?branch=master"><img src="https://coveralls.io/repos/github/Haixing-Hu/js-json/badge.svg?branch=master" alt="Coverage Status"></a></p>
|
|
57
|
-
<p><a href="https://npmjs.com/package/@qubit-ltd/json">@qubit-ltd/json</a>
|
|
57
|
+
<p><a href="https://npmjs.com/package/@qubit-ltd/json">@qubit-ltd/json</a> is a JavaScript library that extends the functionality of the
|
|
58
58
|
standard JSON object, providing robust support for working with numbers that
|
|
59
|
-
exceed JavaScript
|
|
59
|
+
exceed JavaScript's safe range. It offers enhanced parsing and stringifying
|
|
60
60
|
capabilities, making it ideal for handling large datasets and complex numerical
|
|
61
|
-
operations while adhering to JSON
|
|
61
|
+
operations while adhering to JSON's structure.</p>
|
|
62
62
|
<h2>Key Features</h2>
|
|
63
63
|
<ul>
|
|
64
|
-
<li><code>BigInt</code> Support
|
|
64
|
+
<li><strong><code>BigInt</code> Support</strong>: When parsing JSON strings, numbers outside JavaScript's safe
|
|
65
65
|
integer range are automatically converted to the native <code>BigInt</code>, ensuring
|
|
66
66
|
precision is maintained.</li>
|
|
67
|
-
<li><code>LosslessNumber</code> Handling
|
|
67
|
+
<li><strong><code>LosslessNumber</code> Handling</strong>: For floating-point numbers that cannot be accurately
|
|
68
68
|
represented in JavaScript, this library introduces the <code>LosslessNumber</code> object.
|
|
69
69
|
This lightweight object preserves the full precision of the number as a string,
|
|
70
70
|
allowing flexible conversion to number or <code>BigInt</code> for mathematical operations.</li>
|
|
71
|
-
<li>Accurate Stringification
|
|
72
|
-
serialized as strings without the
|
|
71
|
+
<li><strong>Accurate Stringification</strong>: During the stringify process, <code>BigInt</code> values are
|
|
72
|
+
serialized as strings without the "n" suffix, maintaining compatibility with
|
|
73
73
|
the standard JSON format. Similarly, <code>LosslessNumber</code> objects are serialized
|
|
74
74
|
using their internal string representation.</li>
|
|
75
|
-
<li>Collection Serialization
|
|
75
|
+
<li><strong>Collection Serialization</strong>: JavaScript's native collections like <code>Set</code> and <code>Map</code>
|
|
76
76
|
are seamlessly serialized as arrays, allowing for better compatibility with
|
|
77
77
|
JSON structures.</li>
|
|
78
78
|
</ul>
|
|
@@ -93,44 +93,88 @@ enhanced capabilities for handling large integers, floating-point numbers, and
|
|
|
93
93
|
collections like Set and Map.</p>
|
|
94
94
|
<pre class="prettyprint source lang-javascript"><code>import Json from '@qubit-ltd/json';
|
|
95
95
|
|
|
96
|
-
//
|
|
96
|
+
// Parse numbers outside the safe range
|
|
97
97
|
const str1 = '{"decimal":2.370,"big_int":9123372036854000123,"big_float":2.3e+500}';
|
|
98
|
-
const obj1 = Json.parse(
|
|
98
|
+
const obj1 = Json.parse(str1);
|
|
99
99
|
console.log(obj1.decimal); // 2.37
|
|
100
100
|
console.log(obj1.big_int); // 9123372036854000123n
|
|
101
101
|
console.log(obj1.big_float); // LosslessNumber { value: '2.3e+500', isLosslessNumber: true }
|
|
102
102
|
console.log(String(obj1.big_float)); // '2.3e+500'
|
|
103
103
|
|
|
104
|
-
//
|
|
104
|
+
// Stringify numbers outside the safe range
|
|
105
105
|
const json1 = Json.stringify(obj1);
|
|
106
106
|
console.log(json1); // '{"decimal":2.37,"big_int":9123372036854000123,"big_float":"2.3e+500"}'
|
|
107
107
|
|
|
108
|
-
//
|
|
108
|
+
// Stringify collections
|
|
109
109
|
const obj2 = {
|
|
110
110
|
x: new Set([{ a: 1 }, { b: 2 }, { c: 3 }]),
|
|
111
111
|
y: new Map([[1, { a: 2 }], [2, { b: 4 }]]),
|
|
112
112
|
};
|
|
113
|
-
const json2 = Json.stringify(
|
|
113
|
+
const json2 = Json.stringify(obj2);
|
|
114
114
|
console.log(json2); // '{"x":[{"a":1},{"b":2},{"c":3}],"y":[[1,{"a":2}],[2,{"b":4}]]}'
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
// Pretty-print with indentation
|
|
117
|
+
const json3 = Json.stringify(obj2, null, 2);
|
|
118
|
+
console.log(json3);
|
|
119
|
+
/* Output:
|
|
120
|
+
{
|
|
121
|
+
"x": [
|
|
122
|
+
{
|
|
123
|
+
"a": 1
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"b": 2
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"c": 3
|
|
130
|
+
}
|
|
131
|
+
],
|
|
132
|
+
"y": [
|
|
133
|
+
[
|
|
134
|
+
1,
|
|
135
|
+
{
|
|
136
|
+
"a": 2
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
[
|
|
140
|
+
2,
|
|
141
|
+
{
|
|
142
|
+
"b": 4
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
*/
|
|
118
148
|
</code></pre>
|
|
119
149
|
<h3>LosslessNumber Class</h3>
|
|
120
|
-
<p>The LosslessNumber class is used to handle floating-point numbers with full
|
|
150
|
+
<p>The <code>LosslessNumber</code> class is used to handle floating-point numbers with full
|
|
121
151
|
precision, avoiding truncation or rounding issues.</p>
|
|
122
152
|
<pre class="prettyprint source lang-javascript"><code>import Json from '@qubit-ltd/json';
|
|
153
|
+
import { LosslessNumber } from '@qubit-ltd/json';
|
|
154
|
+
|
|
155
|
+
// Parse a number with high precision
|
|
123
156
|
const parsed = Json.parse('{"float": 1.234567891234567891234}');
|
|
124
157
|
console.log(parsed.float); // LosslessNumber { value: '1.234567891234567891234' }
|
|
125
158
|
|
|
126
159
|
// Convert LosslessNumber to standard number
|
|
127
|
-
console.log(parsed.float.valueOf()); // 1.2345678912345679 (standard JS number)
|
|
160
|
+
console.log(parsed.float.valueOf()); // 1.2345678912345679 (standard JS number, precision loss)
|
|
161
|
+
|
|
162
|
+
// Create a LosslessNumber directly
|
|
163
|
+
const largeNumber = new LosslessNumber('9876543210.123456789012345678901234567890');
|
|
164
|
+
console.log(largeNumber.toString()); // '9876543210.123456789012345678901234567890'
|
|
165
|
+
console.log(largeNumber.valueOf()); // 9876543210.123457 (standard JS number with precision loss)
|
|
166
|
+
|
|
167
|
+
// Mathematical operations
|
|
168
|
+
const num1 = new LosslessNumber('1234567890.123456789');
|
|
169
|
+
const num2 = 100;
|
|
170
|
+
// For math operations, LosslessNumber is converted to standard number (with potential precision loss)
|
|
171
|
+
console.log(num1 * num2); // 123456789012.34578
|
|
128
172
|
</code></pre>
|
|
129
173
|
<h3>Utility Functions</h3>
|
|
130
174
|
<p>This library provides a set of utility functions to aid in the handling of large
|
|
131
175
|
numbers and ensure safe conversions.</p>
|
|
132
176
|
<h4><code>isBigInt(value)</code></h4>
|
|
133
|
-
<p>Checks if a string represents a <code>BigInt</code> (i.e., ends with an
|
|
177
|
+
<p>Checks if a string represents a <code>BigInt</code> (i.e., ends with an "n" suffix).</p>
|
|
134
178
|
<pre class="prettyprint source lang-javascript"><code>import { isBigInt } from '@qubit-ltd/json';
|
|
135
179
|
|
|
136
180
|
console.log(isBigInt('12345n')); // true
|
|
@@ -142,6 +186,8 @@ console.log(isBigInt('12345')); // false
|
|
|
142
186
|
|
|
143
187
|
console.log(isInteger('12345')); // true
|
|
144
188
|
console.log(isInteger('123.45')); // false
|
|
189
|
+
console.log(isInteger('123e5')); // true (12300000 is an integer)
|
|
190
|
+
console.log(isInteger('123e-5')); // false (0.00123 is not an integer)
|
|
145
191
|
</code></pre>
|
|
146
192
|
<h4><code>isNumber(value)</code></h4>
|
|
147
193
|
<p>Checks if a string represents a number.</p>
|
|
@@ -151,25 +197,32 @@ console.log(isNumber('12345')); // true
|
|
|
151
197
|
console.log(isNumber('-123.45')); // true
|
|
152
198
|
console.log(isNumber('1.23e-11')); // true
|
|
153
199
|
console.log(isNumber('abc')); // false
|
|
200
|
+
console.log(isNumber('123abc')); // false
|
|
201
|
+
console.log(isNumber('0xFF')); // false (hexadecimal notation not supported)
|
|
154
202
|
</code></pre>
|
|
155
203
|
<h4><code>isSafeNumber(value, options)</code></h4>
|
|
156
|
-
<p>Checks if a string represents a number within JavaScript
|
|
204
|
+
<p>Checks if a string represents a number within JavaScript's safe range.</p>
|
|
157
205
|
<pre class="prettyprint source lang-javascript"><code>import { isSafeNumber } from '@qubit-ltd/json';
|
|
158
206
|
|
|
159
207
|
console.log(isSafeNumber('12345')); // true
|
|
160
|
-
console.log(isSafeNumber('12345678901234567890')); // false
|
|
161
|
-
console.log(isSafeNumber('123.45678901234567890')); // false
|
|
162
|
-
|
|
208
|
+
console.log(isSafeNumber('12345678901234567890')); // false (too large for JavaScript's number type)
|
|
209
|
+
console.log(isSafeNumber('123.45678901234567890')); // false (too many significant digits)
|
|
210
|
+
|
|
211
|
+
// With options
|
|
212
|
+
console.log(isSafeNumber('123.45678901234567890', {
|
|
213
|
+
approx: true, // Allow approximate representation
|
|
214
|
+
requiredDigits: 16 // Require at least 16 digits of precision
|
|
215
|
+
})); // true
|
|
163
216
|
</code></pre>
|
|
164
217
|
<h4><code>getUnsafeReason(value)</code></h4>
|
|
165
218
|
<p>Explains why a number represented by a string is unsafe, returning one of the
|
|
166
219
|
following reasons:</p>
|
|
167
220
|
<ul>
|
|
168
|
-
<li><code>'overflow'</code
|
|
169
|
-
<li><code>'underflow'</code
|
|
170
|
-
<li><code>'truncate_integer'</code
|
|
171
|
-
<li><code>'truncate_float'</code
|
|
172
|
-
<li><code>'none'</code>:
|
|
221
|
+
<li><code>'overflow'</code>: The number is too large to be represented in JavaScript</li>
|
|
222
|
+
<li><code>'underflow'</code>: The number is too small to be represented in JavaScript</li>
|
|
223
|
+
<li><code>'truncate_integer'</code>: The integer part would be truncated if converted to a JavaScript number</li>
|
|
224
|
+
<li><code>'truncate_float'</code>: The floating-point part would lose precision if converted to a JavaScript number</li>
|
|
225
|
+
<li><code>'none'</code>: The value is safe to convert to a JavaScript number</li>
|
|
173
226
|
</ul>
|
|
174
227
|
<pre class="prettyprint source lang-javascript"><code>import { getUnsafeReason } from '@qubit-ltd/json';
|
|
175
228
|
|
|
@@ -181,7 +234,7 @@ console.log(getUnsafeReason('1e-324')); // Output: 'underflow'
|
|
|
181
234
|
</code></pre>
|
|
182
235
|
<h4><code>toSafeNumberOrThrow(value, options)</code></h4>
|
|
183
236
|
<p>Converts a string into a number if it is safe to do so. Throws an error if the
|
|
184
|
-
number is unsafe, explaining the reason.</p>
|
|
237
|
+
number is unsafe, explaining the reason. This is useful for validating numeric inputs.</p>
|
|
185
238
|
<pre class="prettyprint source lang-javascript"><code>import { toSafeNumberOrThrow } from '@qubit-ltd/json';
|
|
186
239
|
|
|
187
240
|
try {
|
|
@@ -190,11 +243,125 @@ try {
|
|
|
190
243
|
console.error(e.message); // Output: 'Cannot safely convert to number: the value '-12345678901234567890' would truncate integer and become -12345678901234567000'
|
|
191
244
|
}
|
|
192
245
|
|
|
246
|
+
// Safe conversion example
|
|
193
247
|
console.log(toSafeNumberOrThrow('9007199254740991')); // Output: 9007199254740991
|
|
248
|
+
|
|
249
|
+
// With options
|
|
250
|
+
try {
|
|
251
|
+
console.log(toSafeNumberOrThrow('123.45678901234567890', {
|
|
252
|
+
approx: false, // Do not allow approximate representation
|
|
253
|
+
requiredDigits: 20 // Require at least 20 digits of precision
|
|
254
|
+
}));
|
|
255
|
+
} catch (e) {
|
|
256
|
+
console.error(e.message); // Will throw error about precision loss
|
|
257
|
+
}
|
|
258
|
+
</code></pre>
|
|
259
|
+
<h2>Advanced Usage</h2>
|
|
260
|
+
<h3>Custom Parsing Options</h3>
|
|
261
|
+
<p>You can customize how numbers are parsed using options:</p>
|
|
262
|
+
<pre class="prettyprint source lang-javascript"><code>import Json from '@qubit-ltd/json';
|
|
263
|
+
|
|
264
|
+
const json = '{"bigInt": 9007199254740993, "largeFloat": 1.234567890123456789}';
|
|
265
|
+
|
|
266
|
+
// Use custom parsing options
|
|
267
|
+
const result = Json.parse(json, {
|
|
268
|
+
useBigInt: true, // Default is true - convert large integers to BigInt
|
|
269
|
+
losslessNumbers: true, // Default is true - use LosslessNumber for high-precision floats
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
console.log(typeof result.bigInt); // 'bigint'
|
|
273
|
+
console.log(result.bigInt); // 9007199254740993n
|
|
274
|
+
console.log(result.largeFloat); // LosslessNumber { value: '1.234567890123456789' }
|
|
275
|
+
|
|
276
|
+
// Disable custom number handling
|
|
277
|
+
const standardResult = Json.parse(json, {
|
|
278
|
+
useBigInt: false,
|
|
279
|
+
losslessNumbers: false,
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
console.log(typeof standardResult.bigInt); // 'number'
|
|
283
|
+
console.log(standardResult.bigInt); // 9007199254740992 (precision loss!)
|
|
284
|
+
console.log(standardResult.largeFloat); // 1.2345678901234568 (precision loss!)
|
|
285
|
+
</code></pre>
|
|
286
|
+
<h3>Custom Stringification Options</h3>
|
|
287
|
+
<p>You can customize how values are stringified:</p>
|
|
288
|
+
<pre class="prettyprint source lang-javascript"><code>import Json from '@qubit-ltd/json';
|
|
289
|
+
|
|
290
|
+
const data = {
|
|
291
|
+
bigInt: BigInt('9007199254740993'),
|
|
292
|
+
largeFloat: new LosslessNumber('1.234567890123456789'),
|
|
293
|
+
set: new Set([1, 2, 3]),
|
|
294
|
+
map: new Map([['a', 1], ['b', 2]]),
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
// Default stringification (handles BigInt, LosslessNumber, Set, Map)
|
|
298
|
+
console.log(Json.stringify(data));
|
|
299
|
+
// '{"bigInt":9007199254740993,"largeFloat":"1.234567890123456789","set":[1,2,3],"map":[["a",1],["b",2]]}'
|
|
300
|
+
|
|
301
|
+
// With custom options and indentation
|
|
302
|
+
console.log(Json.stringify(data, null, 2));
|
|
303
|
+
/* Output:
|
|
304
|
+
{
|
|
305
|
+
"bigInt": 9007199254740993,
|
|
306
|
+
"largeFloat": "1.234567890123456789",
|
|
307
|
+
"set": [
|
|
308
|
+
1,
|
|
309
|
+
2,
|
|
310
|
+
3
|
|
311
|
+
],
|
|
312
|
+
"map": [
|
|
313
|
+
[
|
|
314
|
+
"a",
|
|
315
|
+
1
|
|
316
|
+
],
|
|
317
|
+
[
|
|
318
|
+
"b",
|
|
319
|
+
2
|
|
320
|
+
]
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
*/
|
|
194
324
|
</code></pre>
|
|
195
325
|
<h2><span id="contributing">Contributing</span></h2>
|
|
196
326
|
<p>If you find any issues or have suggestions for improvements, please feel free
|
|
197
327
|
to open an issue or submit a pull request to the <a href="https://github.com/Haixing-Hu/js-json">GitHub repository</a>.</p>
|
|
328
|
+
<h3>Development Setup</h3>
|
|
329
|
+
<ol>
|
|
330
|
+
<li>
|
|
331
|
+
<p>Clone the repository:</p>
|
|
332
|
+
<pre class="prettyprint source lang-sh"><code>git clone https://github.com/Haixing-Hu/js-json.git
|
|
333
|
+
cd js-json
|
|
334
|
+
</code></pre>
|
|
335
|
+
</li>
|
|
336
|
+
<li>
|
|
337
|
+
<p>Install dependencies:</p>
|
|
338
|
+
<pre class="prettyprint source lang-sh"><code>yarn install
|
|
339
|
+
</code></pre>
|
|
340
|
+
</li>
|
|
341
|
+
<li>
|
|
342
|
+
<p>Run tests:</p>
|
|
343
|
+
<pre class="prettyprint source lang-sh"><code>yarn test
|
|
344
|
+
</code></pre>
|
|
345
|
+
</li>
|
|
346
|
+
<li>
|
|
347
|
+
<p>Build the library:</p>
|
|
348
|
+
<pre class="prettyprint source lang-sh"><code>yarn build
|
|
349
|
+
</code></pre>
|
|
350
|
+
</li>
|
|
351
|
+
</ol>
|
|
352
|
+
<h3>Release Process</h3>
|
|
353
|
+
<ol>
|
|
354
|
+
<li>Update version in package.json</li>
|
|
355
|
+
<li>Run tests and linting:<pre class="prettyprint source lang-sh"><code>yarn lint && yarn test
|
|
356
|
+
</code></pre>
|
|
357
|
+
</li>
|
|
358
|
+
<li>Build the library:<pre class="prettyprint source lang-sh"><code>yarn build:all
|
|
359
|
+
</code></pre>
|
|
360
|
+
</li>
|
|
361
|
+
<li>Publish to npm:<pre class="prettyprint source lang-sh"><code>yarn deploy
|
|
362
|
+
</code></pre>
|
|
363
|
+
</li>
|
|
364
|
+
</ol>
|
|
198
365
|
<h2><span id="license">License</span></h2>
|
|
199
366
|
<p><a href="https://npmjs.com/package/@qubit-ltd/json">@qubit-ltd/json</a> is distributed under the Apache 2.0 license.
|
|
200
367
|
See the <a href="LICENSE">LICENSE</a> file for more details.</p>
|
|
@@ -226,7 +393,7 @@ in shaping the functionality of this library.</p></article>
|
|
|
226
393
|
|
|
227
394
|
<footer>
|
|
228
395
|
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.4</a>
|
|
229
|
-
on
|
|
396
|
+
on Wed Apr 16 2025 18:02:33 GMT+0800 (China Standard Time)
|
|
230
397
|
using the <a href="https://github.com/Haixing-Hu/jsdoc-minami">customized Minami theme</a>.
|
|
231
398
|
</footer>
|
|
232
399
|
|
|
@@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {
|
|
|
4929
4929
|
</script>
|
|
4930
4930
|
<script>
|
|
4931
4931
|
/*<!--*/
|
|
4932
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"json.min.mjs","children":[{"name":"node_modules/json-custom-numbers","children":[{"uid":"
|
|
4932
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"json.min.mjs","children":[{"name":"node_modules/json-custom-numbers","children":[{"uid":"90e2db19-1","name":"parse.mjs"},{"uid":"90e2db19-3","name":"stringify.mjs"}]},{"name":"src","children":[{"name":"utils","children":[{"uid":"90e2db19-5","name":"is-integer.js"},{"uid":"90e2db19-7","name":"extract-significant-digits.js"},{"uid":"90e2db19-9","name":"is-number.js"},{"uid":"90e2db19-11","name":"is-safe-number.js"},{"uid":"90e2db19-13","name":"get-unsafe-reason.js"},{"uid":"90e2db19-15","name":"lossless-number.js"},{"uid":"90e2db19-25","name":"is-bigint.js"},{"uid":"90e2db19-27","name":"to-safe-number-or-throw.js"}]},{"uid":"90e2db19-17","name":"parse-number.js"},{"uid":"90e2db19-19","name":"format-number.js"},{"uid":"90e2db19-21","name":"collection-replacer.js"},{"uid":"90e2db19-23","name":"json.js"},{"uid":"90e2db19-29","name":"index.js"}]}]}],"isRoot":true},"nodeParts":{"90e2db19-1":{"renderedLength":5058,"gzipLength":2142,"brotliLength":1928,"metaUid":"90e2db19-0"},"90e2db19-3":{"renderedLength":2678,"gzipLength":1398,"brotliLength":1240,"metaUid":"90e2db19-2"},"90e2db19-5":{"renderedLength":669,"gzipLength":321,"brotliLength":274,"metaUid":"90e2db19-4"},"90e2db19-7":{"renderedLength":1065,"gzipLength":464,"brotliLength":388,"metaUid":"90e2db19-6"},"90e2db19-9":{"renderedLength":787,"gzipLength":408,"brotliLength":317,"metaUid":"90e2db19-8"},"90e2db19-11":{"renderedLength":3100,"gzipLength":1083,"brotliLength":861,"metaUid":"90e2db19-10"},"90e2db19-13":{"renderedLength":1108,"gzipLength":441,"brotliLength":365,"metaUid":"90e2db19-12"},"90e2db19-15":{"renderedLength":2673,"gzipLength":1033,"brotliLength":854,"metaUid":"90e2db19-14"},"90e2db19-17":{"renderedLength":834,"gzipLength":358,"brotliLength":290,"metaUid":"90e2db19-16"},"90e2db19-19":{"renderedLength":1045,"gzipLength":382,"brotliLength":321,"metaUid":"90e2db19-18"},"90e2db19-21":{"renderedLength":862,"gzipLength":340,"brotliLength":295,"metaUid":"90e2db19-20"},"90e2db19-23":{"renderedLength":904,"gzipLength":416,"brotliLength":327,"metaUid":"90e2db19-22"},"90e2db19-25":{"renderedLength":670,"gzipLength":324,"brotliLength":252,"metaUid":"90e2db19-24"},"90e2db19-27":{"renderedLength":1512,"gzipLength":636,"brotliLength":533,"metaUid":"90e2db19-26"},"90e2db19-29":{"renderedLength":264,"gzipLength":101,"brotliLength":98,"metaUid":"90e2db19-28"}},"nodeMetas":{"90e2db19-0":{"id":"/node_modules/json-custom-numbers/parse.mjs","moduleParts":{"json.min.mjs":"90e2db19-1"},"imported":[],"importedBy":[{"uid":"90e2db19-30"}]},"90e2db19-2":{"id":"/node_modules/json-custom-numbers/stringify.mjs","moduleParts":{"json.min.mjs":"90e2db19-3"},"imported":[],"importedBy":[{"uid":"90e2db19-30"}]},"90e2db19-4":{"id":"/src/utils/is-integer.js","moduleParts":{"json.min.mjs":"90e2db19-5"},"imported":[],"importedBy":[{"uid":"90e2db19-28"},{"uid":"90e2db19-10"},{"uid":"90e2db19-12"},{"uid":"90e2db19-16"}]},"90e2db19-6":{"id":"/src/utils/extract-significant-digits.js","moduleParts":{"json.min.mjs":"90e2db19-7"},"imported":[],"importedBy":[{"uid":"90e2db19-10"},{"uid":"90e2db19-12"}]},"90e2db19-8":{"id":"/src/utils/is-number.js","moduleParts":{"json.min.mjs":"90e2db19-9"},"imported":[],"importedBy":[{"uid":"90e2db19-28"},{"uid":"90e2db19-14"},{"uid":"90e2db19-10"}]},"90e2db19-10":{"id":"/src/utils/is-safe-number.js","moduleParts":{"json.min.mjs":"90e2db19-11"},"imported":[{"uid":"90e2db19-4"},{"uid":"90e2db19-6"},{"uid":"90e2db19-8"}],"importedBy":[{"uid":"90e2db19-28"},{"uid":"90e2db19-26"},{"uid":"90e2db19-16"}]},"90e2db19-12":{"id":"/src/utils/get-unsafe-reason.js","moduleParts":{"json.min.mjs":"90e2db19-13"},"imported":[{"uid":"90e2db19-4"},{"uid":"90e2db19-6"}],"importedBy":[{"uid":"90e2db19-28"},{"uid":"90e2db19-14"},{"uid":"90e2db19-26"}]},"90e2db19-14":{"id":"/src/utils/lossless-number.js","moduleParts":{"json.min.mjs":"90e2db19-15"},"imported":[{"uid":"90e2db19-31"},{"uid":"90e2db19-32"},{"uid":"90e2db19-33"},{"uid":"90e2db19-8"},{"uid":"90e2db19-12"}],"importedBy":[{"uid":"90e2db19-28"},{"uid":"90e2db19-16"},{"uid":"90e2db19-18"}]},"90e2db19-16":{"id":"/src/parse-number.js","moduleParts":{"json.min.mjs":"90e2db19-17"},"imported":[{"uid":"90e2db19-4"},{"uid":"90e2db19-10"},{"uid":"90e2db19-14"}],"importedBy":[{"uid":"90e2db19-22"}]},"90e2db19-18":{"id":"/src/format-number.js","moduleParts":{"json.min.mjs":"90e2db19-19"},"imported":[{"uid":"90e2db19-14"}],"importedBy":[{"uid":"90e2db19-22"}]},"90e2db19-20":{"id":"/src/collection-replacer.js","moduleParts":{"json.min.mjs":"90e2db19-21"},"imported":[],"importedBy":[{"uid":"90e2db19-22"}]},"90e2db19-22":{"id":"/src/json.js","moduleParts":{"json.min.mjs":"90e2db19-23"},"imported":[{"uid":"90e2db19-30"},{"uid":"90e2db19-16"},{"uid":"90e2db19-18"},{"uid":"90e2db19-20"}],"importedBy":[{"uid":"90e2db19-28"}]},"90e2db19-24":{"id":"/src/utils/is-bigint.js","moduleParts":{"json.min.mjs":"90e2db19-25"},"imported":[],"importedBy":[{"uid":"90e2db19-28"}]},"90e2db19-26":{"id":"/src/utils/to-safe-number-or-throw.js","moduleParts":{"json.min.mjs":"90e2db19-27"},"imported":[{"uid":"90e2db19-12"},{"uid":"90e2db19-10"}],"importedBy":[{"uid":"90e2db19-28"}]},"90e2db19-28":{"id":"/src/index.js","moduleParts":{"json.min.mjs":"90e2db19-29"},"imported":[{"uid":"90e2db19-22"},{"uid":"90e2db19-14"},{"uid":"90e2db19-24"},{"uid":"90e2db19-4"},{"uid":"90e2db19-8"},{"uid":"90e2db19-10"},{"uid":"90e2db19-12"},{"uid":"90e2db19-26"}],"importedBy":[],"isEntry":true},"90e2db19-30":{"id":"/node_modules/json-custom-numbers/index.mjs","moduleParts":{},"imported":[{"uid":"90e2db19-0"},{"uid":"90e2db19-2"}],"importedBy":[{"uid":"90e2db19-22"}]},"90e2db19-31":{"id":"@babel/runtime/helpers/classCallCheck","moduleParts":{},"imported":[],"importedBy":[{"uid":"90e2db19-14"}],"isExternal":true},"90e2db19-32":{"id":"@babel/runtime/helpers/createClass","moduleParts":{},"imported":[],"importedBy":[{"uid":"90e2db19-14"}],"isExternal":true},"90e2db19-33":{"id":"@babel/runtime/helpers/defineProperty","moduleParts":{},"imported":[],"importedBy":[{"uid":"90e2db19-14"}],"isExternal":true}},"env":{"rollup":"4.40.0"},"options":{"gzip":true,"brotli":true,"sourcemap":false}};
|
|
4933
4933
|
|
|
4934
4934
|
const run = () => {
|
|
4935
4935
|
const width = window.innerWidth;
|
|
@@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {
|
|
|
4929
4929
|
</script>
|
|
4930
4930
|
<script>
|
|
4931
4931
|
/*<!--*/
|
|
4932
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"json.mjs","children":[{"name":"node_modules/json-custom-numbers","children":[{"uid":"
|
|
4932
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"json.mjs","children":[{"name":"node_modules/json-custom-numbers","children":[{"uid":"361047d1-1","name":"parse.mjs"},{"uid":"361047d1-3","name":"stringify.mjs"}]},{"name":"src","children":[{"name":"utils","children":[{"uid":"361047d1-5","name":"is-integer.js"},{"uid":"361047d1-7","name":"extract-significant-digits.js"},{"uid":"361047d1-9","name":"is-number.js"},{"uid":"361047d1-11","name":"is-safe-number.js"},{"uid":"361047d1-13","name":"get-unsafe-reason.js"},{"uid":"361047d1-15","name":"lossless-number.js"},{"uid":"361047d1-25","name":"is-bigint.js"},{"uid":"361047d1-27","name":"to-safe-number-or-throw.js"}]},{"uid":"361047d1-17","name":"parse-number.js"},{"uid":"361047d1-19","name":"format-number.js"},{"uid":"361047d1-21","name":"collection-replacer.js"},{"uid":"361047d1-23","name":"json.js"},{"uid":"361047d1-29","name":"index.js"}]}]}],"isRoot":true},"nodeParts":{"361047d1-1":{"renderedLength":5058,"gzipLength":2142,"brotliLength":1928,"metaUid":"361047d1-0"},"361047d1-3":{"renderedLength":2678,"gzipLength":1398,"brotliLength":1240,"metaUid":"361047d1-2"},"361047d1-5":{"renderedLength":669,"gzipLength":321,"brotliLength":274,"metaUid":"361047d1-4"},"361047d1-7":{"renderedLength":1065,"gzipLength":464,"brotliLength":388,"metaUid":"361047d1-6"},"361047d1-9":{"renderedLength":787,"gzipLength":408,"brotliLength":317,"metaUid":"361047d1-8"},"361047d1-11":{"renderedLength":3100,"gzipLength":1083,"brotliLength":861,"metaUid":"361047d1-10"},"361047d1-13":{"renderedLength":1108,"gzipLength":441,"brotliLength":365,"metaUid":"361047d1-12"},"361047d1-15":{"renderedLength":2673,"gzipLength":1033,"brotliLength":854,"metaUid":"361047d1-14"},"361047d1-17":{"renderedLength":834,"gzipLength":358,"brotliLength":290,"metaUid":"361047d1-16"},"361047d1-19":{"renderedLength":1045,"gzipLength":382,"brotliLength":321,"metaUid":"361047d1-18"},"361047d1-21":{"renderedLength":862,"gzipLength":340,"brotliLength":295,"metaUid":"361047d1-20"},"361047d1-23":{"renderedLength":904,"gzipLength":416,"brotliLength":327,"metaUid":"361047d1-22"},"361047d1-25":{"renderedLength":670,"gzipLength":324,"brotliLength":252,"metaUid":"361047d1-24"},"361047d1-27":{"renderedLength":1512,"gzipLength":636,"brotliLength":533,"metaUid":"361047d1-26"},"361047d1-29":{"renderedLength":263,"gzipLength":100,"brotliLength":97,"metaUid":"361047d1-28"}},"nodeMetas":{"361047d1-0":{"id":"/node_modules/json-custom-numbers/parse.mjs","moduleParts":{"json.mjs":"361047d1-1"},"imported":[],"importedBy":[{"uid":"361047d1-30"}]},"361047d1-2":{"id":"/node_modules/json-custom-numbers/stringify.mjs","moduleParts":{"json.mjs":"361047d1-3"},"imported":[],"importedBy":[{"uid":"361047d1-30"}]},"361047d1-4":{"id":"/src/utils/is-integer.js","moduleParts":{"json.mjs":"361047d1-5"},"imported":[],"importedBy":[{"uid":"361047d1-28"},{"uid":"361047d1-10"},{"uid":"361047d1-12"},{"uid":"361047d1-16"}]},"361047d1-6":{"id":"/src/utils/extract-significant-digits.js","moduleParts":{"json.mjs":"361047d1-7"},"imported":[],"importedBy":[{"uid":"361047d1-10"},{"uid":"361047d1-12"}]},"361047d1-8":{"id":"/src/utils/is-number.js","moduleParts":{"json.mjs":"361047d1-9"},"imported":[],"importedBy":[{"uid":"361047d1-28"},{"uid":"361047d1-14"},{"uid":"361047d1-10"}]},"361047d1-10":{"id":"/src/utils/is-safe-number.js","moduleParts":{"json.mjs":"361047d1-11"},"imported":[{"uid":"361047d1-4"},{"uid":"361047d1-6"},{"uid":"361047d1-8"}],"importedBy":[{"uid":"361047d1-28"},{"uid":"361047d1-26"},{"uid":"361047d1-16"}]},"361047d1-12":{"id":"/src/utils/get-unsafe-reason.js","moduleParts":{"json.mjs":"361047d1-13"},"imported":[{"uid":"361047d1-4"},{"uid":"361047d1-6"}],"importedBy":[{"uid":"361047d1-28"},{"uid":"361047d1-14"},{"uid":"361047d1-26"}]},"361047d1-14":{"id":"/src/utils/lossless-number.js","moduleParts":{"json.mjs":"361047d1-15"},"imported":[{"uid":"361047d1-31"},{"uid":"361047d1-32"},{"uid":"361047d1-33"},{"uid":"361047d1-8"},{"uid":"361047d1-12"}],"importedBy":[{"uid":"361047d1-28"},{"uid":"361047d1-16"},{"uid":"361047d1-18"}]},"361047d1-16":{"id":"/src/parse-number.js","moduleParts":{"json.mjs":"361047d1-17"},"imported":[{"uid":"361047d1-4"},{"uid":"361047d1-10"},{"uid":"361047d1-14"}],"importedBy":[{"uid":"361047d1-22"}]},"361047d1-18":{"id":"/src/format-number.js","moduleParts":{"json.mjs":"361047d1-19"},"imported":[{"uid":"361047d1-14"}],"importedBy":[{"uid":"361047d1-22"}]},"361047d1-20":{"id":"/src/collection-replacer.js","moduleParts":{"json.mjs":"361047d1-21"},"imported":[],"importedBy":[{"uid":"361047d1-22"}]},"361047d1-22":{"id":"/src/json.js","moduleParts":{"json.mjs":"361047d1-23"},"imported":[{"uid":"361047d1-30"},{"uid":"361047d1-16"},{"uid":"361047d1-18"},{"uid":"361047d1-20"}],"importedBy":[{"uid":"361047d1-28"}]},"361047d1-24":{"id":"/src/utils/is-bigint.js","moduleParts":{"json.mjs":"361047d1-25"},"imported":[],"importedBy":[{"uid":"361047d1-28"}]},"361047d1-26":{"id":"/src/utils/to-safe-number-or-throw.js","moduleParts":{"json.mjs":"361047d1-27"},"imported":[{"uid":"361047d1-12"},{"uid":"361047d1-10"}],"importedBy":[{"uid":"361047d1-28"}]},"361047d1-28":{"id":"/src/index.js","moduleParts":{"json.mjs":"361047d1-29"},"imported":[{"uid":"361047d1-22"},{"uid":"361047d1-14"},{"uid":"361047d1-24"},{"uid":"361047d1-4"},{"uid":"361047d1-8"},{"uid":"361047d1-10"},{"uid":"361047d1-12"},{"uid":"361047d1-26"}],"importedBy":[],"isEntry":true},"361047d1-30":{"id":"/node_modules/json-custom-numbers/index.mjs","moduleParts":{},"imported":[{"uid":"361047d1-0"},{"uid":"361047d1-2"}],"importedBy":[{"uid":"361047d1-22"}]},"361047d1-31":{"id":"@babel/runtime/helpers/classCallCheck","moduleParts":{},"imported":[],"importedBy":[{"uid":"361047d1-14"}],"isExternal":true},"361047d1-32":{"id":"@babel/runtime/helpers/createClass","moduleParts":{},"imported":[],"importedBy":[{"uid":"361047d1-14"}],"isExternal":true},"361047d1-33":{"id":"@babel/runtime/helpers/defineProperty","moduleParts":{},"imported":[],"importedBy":[{"uid":"361047d1-14"}],"isExternal":true}},"env":{"rollup":"4.40.0"},"options":{"gzip":true,"brotli":true,"sourcemap":false}};
|
|
4933
4933
|
|
|
4934
4934
|
const run = () => {
|
|
4935
4935
|
const width = window.innerWidth;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qubit-ltd/json",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A JavaScript library for parsing and formatting JSON data.",
|
|
5
5
|
"author": "Haixing Hu",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,7 +42,9 @@
|
|
|
42
42
|
"lint": "eslint ./src",
|
|
43
43
|
"doc": "jsdoc -c jsdoc.json",
|
|
44
44
|
"es5": "check-es-version -e 5 -s true",
|
|
45
|
-
"deploy": "npm run lint && npm run test && npm run build:all && npm publish --registry='https://
|
|
45
|
+
"deploy": "npm run lint && npm run test && npm run build:all && npm publish --registry='https://npm.qubit.ltd/' --access public",
|
|
46
|
+
"deploy:public": "npm run lint && npm run test && npm run build:all && npm publish --registry='https://registry.npmjs.org/' --access public",
|
|
47
|
+
"deploy:all": "npm run deploy && npm publish --registry='https://registry.npmjs.org/' --access public"
|
|
46
48
|
},
|
|
47
49
|
"dependencies": {
|
|
48
50
|
"json-custom-numbers": "^3.1.1"
|
|
@@ -51,26 +53,26 @@
|
|
|
51
53
|
"@babel/runtime": "^7.26.0"
|
|
52
54
|
},
|
|
53
55
|
"devDependencies": {
|
|
54
|
-
"@babel/core": "^7.26.
|
|
55
|
-
"@babel/eslint-parser": "^7.
|
|
56
|
+
"@babel/core": "^7.26.10",
|
|
57
|
+
"@babel/eslint-parser": "^7.27.0",
|
|
56
58
|
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
57
59
|
"@babel/plugin-transform-class-properties": "^7.25.9",
|
|
58
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
59
|
-
"@babel/preset-env": "^7.26.
|
|
60
|
-
"@babel/runtime": "^7.
|
|
60
|
+
"@babel/plugin-transform-runtime": "^7.26.10",
|
|
61
|
+
"@babel/preset-env": "^7.26.9",
|
|
62
|
+
"@babel/runtime": "^7.27.0",
|
|
61
63
|
"@jest/core": "^29.7.0",
|
|
62
64
|
"@qubit-ltd/eslint-config": "^1.3.4",
|
|
63
65
|
"@qubit-ltd/jsdoc-minami": "^1.5.2",
|
|
64
|
-
"@qubit-ltd/rollup-builder": "^1.8.
|
|
66
|
+
"@qubit-ltd/rollup-builder": "^1.8.9",
|
|
65
67
|
"@rollup/plugin-alias": "^5.1.1",
|
|
66
68
|
"@rollup/plugin-babel": "^6.0.4",
|
|
67
|
-
"@rollup/plugin-commonjs": "^
|
|
69
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
68
70
|
"@rollup/plugin-json": "^6.1.0",
|
|
69
|
-
"@rollup/plugin-node-resolve": "^
|
|
71
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
70
72
|
"@rollup/plugin-terser": "^0.4.4",
|
|
71
73
|
"babel-jest": "^29.7.0",
|
|
72
|
-
"check-es-version": "^1.5.
|
|
73
|
-
"core-js": "^3.
|
|
74
|
+
"check-es-version": "^1.5.1",
|
|
75
|
+
"core-js": "^3.41.0",
|
|
74
76
|
"cross-env": "^7.0.3",
|
|
75
77
|
"eslint": "^8.57.1",
|
|
76
78
|
"eslint-plugin-import": "^2.31.0",
|
|
@@ -79,9 +81,9 @@
|
|
|
79
81
|
"jest-environment-jsdom-global": "^4.0.0",
|
|
80
82
|
"jest-extended": "^4.0.2",
|
|
81
83
|
"jsdoc": "^4.0.4",
|
|
82
|
-
"rollup": "^4.
|
|
84
|
+
"rollup": "^4.40.0",
|
|
83
85
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
84
|
-
"rollup-plugin-visualizer": "^5.
|
|
86
|
+
"rollup-plugin-visualizer": "^5.14.0"
|
|
85
87
|
},
|
|
86
88
|
"packageManager": "yarn@4.5.0"
|
|
87
89
|
}
|