utilitas 1995.2.83 → 1995.2.84

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/lib/horizon.mjs CHANGED
@@ -6,6 +6,11 @@ RegExp.escape = RegExp.escape || (str => { //$& means the whole matched string
6
6
  return String(str).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
7
7
  }); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
8
8
 
9
+ // BigInt
10
+ BigInt.prototype.toJSON = BigInt.prototype.toJSON || function() {
11
+ return this.toString();
12
+ };
13
+
9
14
  // Assert
10
15
  import { default as asst } from 'assert';
11
16
  const _assert = asst || ((val, err) => {
package/lib/manifest.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  const manifest = {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "1995.2.83",
4
+ "version": "1995.2.84",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",
package/lib/utilitas.mjs CHANGED
@@ -267,9 +267,16 @@ const decode = (string, toBuf, encoding) => {
267
267
  return toBuf ? buf : buf.toString('utf8');
268
268
  };
269
269
 
270
- const parseJson = (any, fallback) => {
271
- try { return JSON.parse(any); }
272
- catch (e) { return isSet(fallback) ? fallback : {}; }
270
+ const parseJson = (any, fallback, options) => {
271
+ try {
272
+ return JSON.parse(any, options?.reviver || ((key, value) => {
273
+ if (value && value.type === 'Buffer' && Array.isArray(value.data)) {
274
+ return Buffer.from(value.data);
275
+ }
276
+ return value;
277
+
278
+ }));
279
+ } catch (e) { return isSet(fallback) ? fallback : {}; }
273
280
  };
274
281
 
275
282
  const extract = (...path) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "utilitas",
3
3
  "description": "Just another common utility for JavaScript.",
4
- "version": "1995.2.83",
4
+ "version": "1995.2.84",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",