typeson-registry 10.0.0 → 11.0.1

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.
Files changed (125) hide show
  1. package/README.md +1 -5
  2. package/dist/index.js +40 -42
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/dist/index.umd.cjs +32 -31
  7. package/dist/index.umd.cjs.map +1 -1
  8. package/dist/index.umd.min.cjs +1 -1
  9. package/dist/index.umd.min.cjs.map +1 -1
  10. package/dist/polyfills/createObjectURL.d.ts.map +1 -1
  11. package/dist/presets/array-nonindex-keys.d.ts +1 -1
  12. package/dist/presets/array-nonindex-keys.umd.cjs.map +1 -1
  13. package/dist/presets/builtin.d.ts +1 -1
  14. package/dist/presets/builtin.umd.cjs +1 -1
  15. package/dist/presets/builtin.umd.cjs.map +1 -1
  16. package/dist/presets/postmessage.d.ts +1 -1
  17. package/dist/presets/postmessage.umd.cjs.map +1 -1
  18. package/dist/presets/socketio.d.ts +1 -1
  19. package/dist/presets/socketio.umd.cjs +1 -1
  20. package/dist/presets/socketio.umd.cjs.map +1 -1
  21. package/dist/presets/sparse-undefined.d.ts +1 -1
  22. package/dist/presets/sparse-undefined.umd.cjs.map +1 -1
  23. package/dist/presets/special-numbers.d.ts +1 -1
  24. package/dist/presets/special-numbers.umd.cjs.map +1 -1
  25. package/dist/presets/structured-cloning-throwing.d.ts +1 -1
  26. package/dist/presets/structured-cloning-throwing.umd.cjs +1 -1
  27. package/dist/presets/structured-cloning-throwing.umd.cjs.map +1 -1
  28. package/dist/presets/structured-cloning.d.ts +1 -1
  29. package/dist/presets/structured-cloning.umd.cjs +1 -1
  30. package/dist/presets/structured-cloning.umd.cjs.map +1 -1
  31. package/dist/presets/undef.d.ts +1 -1
  32. package/dist/presets/undef.umd.cjs.map +1 -1
  33. package/dist/presets/universal.d.ts +1 -1
  34. package/dist/presets/universal.umd.cjs +1 -1
  35. package/dist/presets/universal.umd.cjs.map +1 -1
  36. package/dist/types/arraybuffer.d.ts +1 -1
  37. package/dist/types/arraybuffer.umd.cjs.map +1 -1
  38. package/dist/types/bigint-object.d.ts +1 -1
  39. package/dist/types/bigint-object.d.ts.map +1 -1
  40. package/dist/types/bigint-object.umd.cjs.map +1 -1
  41. package/dist/types/bigint.d.ts +1 -1
  42. package/dist/types/bigint.d.ts.map +1 -1
  43. package/dist/types/bigint.umd.cjs.map +1 -1
  44. package/dist/types/blob.d.ts +1 -1
  45. package/dist/types/blob.d.ts.map +1 -1
  46. package/dist/types/blob.umd.cjs +1 -1
  47. package/dist/types/blob.umd.cjs.map +1 -1
  48. package/dist/types/cloneable.d.ts +1 -1
  49. package/dist/types/cloneable.umd.cjs +1 -1
  50. package/dist/types/cloneable.umd.cjs.map +1 -1
  51. package/dist/types/cryptokey.d.ts +1 -1
  52. package/dist/types/cryptokey.d.ts.map +1 -1
  53. package/dist/types/cryptokey.umd.cjs.map +1 -1
  54. package/dist/types/dataview.d.ts +1 -1
  55. package/dist/types/dataview.umd.cjs.map +1 -1
  56. package/dist/types/date.d.ts +1 -1
  57. package/dist/types/date.umd.cjs.map +1 -1
  58. package/dist/types/domexception.d.ts +1 -1
  59. package/dist/types/domexception.umd.cjs.map +1 -1
  60. package/dist/types/dommatrix.d.ts +1 -1
  61. package/dist/types/dommatrix.umd.cjs.map +1 -1
  62. package/dist/types/dompoint.d.ts +1 -1
  63. package/dist/types/dompoint.umd.cjs.map +1 -1
  64. package/dist/types/domquad.d.ts +1 -1
  65. package/dist/types/domquad.umd.cjs.map +1 -1
  66. package/dist/types/domrect.d.ts +1 -1
  67. package/dist/types/domrect.umd.cjs.map +1 -1
  68. package/dist/types/error.d.ts +1 -1
  69. package/dist/types/error.umd.cjs.map +1 -1
  70. package/dist/types/errors.d.ts +1 -1
  71. package/dist/types/errors.d.ts.map +1 -1
  72. package/dist/types/errors.umd.cjs.map +1 -1
  73. package/dist/types/file.d.ts +1 -1
  74. package/dist/types/file.d.ts.map +1 -1
  75. package/dist/types/file.umd.cjs +1 -1
  76. package/dist/types/file.umd.cjs.map +1 -1
  77. package/dist/types/filelist.d.ts +1 -1
  78. package/dist/types/filelist.umd.cjs +1 -1
  79. package/dist/types/filelist.umd.cjs.map +1 -1
  80. package/dist/types/imagebitmap.d.ts +1 -1
  81. package/dist/types/imagebitmap.umd.cjs.map +1 -1
  82. package/dist/types/imagedata.d.ts +1 -1
  83. package/dist/types/imagedata.umd.cjs.map +1 -1
  84. package/dist/types/infinity.d.ts +1 -1
  85. package/dist/types/infinity.umd.cjs.map +1 -1
  86. package/dist/types/intl-types.d.ts +3 -3
  87. package/dist/types/intl-types.umd.cjs.map +1 -1
  88. package/dist/types/map.d.ts +1 -1
  89. package/dist/types/map.umd.cjs.map +1 -1
  90. package/dist/types/nan.d.ts +1 -1
  91. package/dist/types/nan.umd.cjs.map +1 -1
  92. package/dist/types/negative-infinity.d.ts +1 -1
  93. package/dist/types/negative-infinity.umd.cjs.map +1 -1
  94. package/dist/types/negative-zero.d.ts +1 -1
  95. package/dist/types/negative-zero.umd.cjs.map +1 -1
  96. package/dist/types/nonbuiltin-ignore.d.ts +1 -1
  97. package/dist/types/nonbuiltin-ignore.umd.cjs.map +1 -1
  98. package/dist/types/primitive-objects.d.ts +1 -1
  99. package/dist/types/primitive-objects.d.ts.map +1 -1
  100. package/dist/types/primitive-objects.umd.cjs +1 -1
  101. package/dist/types/primitive-objects.umd.cjs.map +1 -1
  102. package/dist/types/regexp.d.ts +1 -1
  103. package/dist/types/regexp.umd.cjs.map +1 -1
  104. package/dist/types/resurrectable.d.ts +1 -1
  105. package/dist/types/resurrectable.umd.cjs +1 -1
  106. package/dist/types/resurrectable.umd.cjs.map +1 -1
  107. package/dist/types/set.d.ts +1 -1
  108. package/dist/types/set.umd.cjs.map +1 -1
  109. package/dist/types/typed-arrays-socketio.d.ts +1 -1
  110. package/dist/types/typed-arrays-socketio.d.ts.map +1 -1
  111. package/dist/types/typed-arrays-socketio.umd.cjs.map +1 -1
  112. package/dist/types/typed-arrays.d.ts +1 -1
  113. package/dist/types/typed-arrays.d.ts.map +1 -1
  114. package/dist/types/typed-arrays.umd.cjs.map +1 -1
  115. package/dist/types/undef.d.ts +1 -1
  116. package/dist/types/undef.umd.cjs.map +1 -1
  117. package/dist/types/user-object.d.ts +1 -1
  118. package/dist/types/user-object.umd.cjs.map +1 -1
  119. package/dist/utils/generateUUID.d.ts.map +1 -1
  120. package/package.json +34 -53
  121. package/polyfills/createObjectURL.js +8 -13
  122. package/polyfills/createObjectURL.umd.cjs +1 -1
  123. package/polyfills/createObjectURL.umd.cjs.map +1 -1
  124. package/utils/generateUUID.js +3 -13
  125. package/tools/append-to-declaration-files.js +0 -13
package/README.md CHANGED
@@ -50,10 +50,6 @@ The `imagedata` type requires a global `ImageData` polyfill (including an
50
50
  You may wish to see our `test-environment.js` file for how some
51
51
  polyfilling may be done (largely using `jsdom`).
52
52
 
53
- The `cloneable` and `resurrectable` types (and the `createObjectURL`
54
- polyill) each accept an optional global `performance` polyfill (through
55
- the common file `utils/generateUUID.js`).
56
-
57
53
  ### Building files from Git clone (as opposed to npm installs)
58
54
 
59
55
  If you have cloned the repo (and not the npm package), you must run
@@ -317,7 +313,7 @@ another context).
317
313
  const functionType = {functionType: [
318
314
  function (x) { return typeof x === 'function'; },
319
315
  function (funcType) { return '(' + funcType.toString() + ')'; },
320
- // eslint-disable-next-line no-eval
316
+ // eslint-disable-next-line no-eval -- Demonstrating
321
317
  function (o) { return eval(o); }
322
318
  ]};
323
319
 
package/dist/index.js CHANGED
@@ -157,8 +157,6 @@ const bigintObject = {
157
157
  },
158
158
  replace: String,
159
159
  revive (s) {
160
- // Filed this to avoid error: https://github.com/eslint/eslint/issues/11810
161
- // eslint-disable-next-line no-new-object
162
160
  return new Object(BigInt(/** @type {string} */ (s)));
163
161
  }
164
162
  }
@@ -173,7 +171,8 @@ const bigint = {
173
171
  return typeof x === 'bigint';
174
172
  },
175
173
  replace: String,
176
- // eslint-disable-next-line unicorn/prefer-native-coercion-functions
174
+ // eslint-disable-next-line @stylistic/max-len -- Long
175
+ // eslint-disable-next-line unicorn/prefer-native-coercion-functions -- Clearer
177
176
  revive (s) {
178
177
  return BigInt(/** @type {string} */ (s));
179
178
  }
@@ -185,6 +184,11 @@ const bigint = {
185
184
  * @param {ArrayBuffer} buf
186
185
  * @returns {string}
187
186
  */
187
+ function arraybuffer2string (buf) {
188
+ return new Uint8Array(buf).reduce(
189
+ (s, byte) => s + String.fromCodePoint(byte), ''
190
+ );
191
+ }
188
192
 
189
193
  /**
190
194
  *
@@ -247,7 +251,7 @@ function string2arraybuffer (str) {
247
251
  return array.buffer;
248
252
  }
249
253
 
250
- /* globals XMLHttpRequest, Blob, FileReader */
254
+ /* globals XMLHttpRequest, FileReader -- Polyfills */
251
255
 
252
256
  /**
253
257
  * @type {import('typeson').TypeSpecSet}
@@ -289,7 +293,9 @@ const blob = {
289
293
  reader.addEventListener('load', () => {
290
294
  resolve({
291
295
  type: b.type,
292
- stringContents: reader.result
296
+ stringContents: arraybuffer2string(
297
+ /** @type {ArrayBuffer} */ (reader.result)
298
+ )
293
299
  });
294
300
  });
295
301
  // Seems not feasible to accurately simulate
@@ -297,14 +303,14 @@ const blob = {
297
303
  reader.addEventListener('error', () => {
298
304
  reject(reader.error);
299
305
  });
300
- reader.readAsBinaryString(b);
306
+ // eslint-disable-next-line @stylistic/max-len -- Long
307
+ // eslint-disable-next-line unicorn/prefer-blob-reading-methods -- Too new?
308
+ reader.readAsArrayBuffer(b);
301
309
  });
302
310
  }
303
311
  }
304
312
  };
305
313
 
306
- // The `performance` global is optional
307
-
308
314
  /**
309
315
  * @todo We could use `import generateUUID from 'uuid/v4';` (but it needs
310
316
  * crypto library, etc.; `rollup-plugin-node-builtins` doesn't recommend
@@ -314,22 +320,14 @@ const blob = {
314
320
  */
315
321
  function generateUUID () { // Adapted from original: public domain/MIT: http://stackoverflow.com/a/8809472/271577
316
322
  /* c8 ignore next */
317
- let d = Date.now() +
318
- // use high-precision timer if available
319
- /* c8 ignore next 4 */
320
- (typeof performance !== 'undefined' &&
321
- typeof performance.now === 'function'
322
- ? performance.now()
323
- : 0);
324
-
325
- // eslint-disable-next-line @stylistic/max-len -- Long
326
- // eslint-disable-next-line no-use-extend-native/no-use-extend-native -- Need to update plugin
323
+ let d = Date.now();
324
+
327
325
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replaceAll(/[xy]/gu, function (c) {
328
- /* eslint-disable no-bitwise */
326
+ /* eslint-disable no-bitwise -- Convenient */
329
327
  const r = Math.trunc((d + (Math.random() * 16)) % 16);
330
328
  d = Math.floor(d / 16);
331
329
  return (c === 'x' ? r : ((r & 0x3) | 0x8)).toString(16);
332
- /* eslint-enable no-bitwise */
330
+ /* eslint-enable no-bitwise -- Convenient */
333
331
  });
334
332
  }
335
333
 
@@ -365,8 +363,6 @@ const cloneable = {
365
363
  }
366
364
  };
367
365
 
368
- /* globals crypto */
369
-
370
366
  /**
371
367
  * @type {import('typeson').TypeSpecSet}
372
368
  */
@@ -520,7 +516,7 @@ const domexception = {
520
516
  }
521
517
  };
522
518
 
523
- /* globals DOMMatrix, DOMMatrixReadOnly */
519
+ /* globals DOMMatrix, DOMMatrixReadOnly -- Polyfills */
524
520
 
525
521
  /**
526
522
  * @type {import('typeson').TypeSpecSet}
@@ -587,7 +583,7 @@ function create$5 (Ctor) {
587
583
  };
588
584
  }
589
585
 
590
- /* globals DOMPoint, DOMPointReadOnly */
586
+ /* globals DOMPoint, DOMPointReadOnly -- Polyfills */
591
587
 
592
588
  /**
593
589
  * @type {import('typeson').TypeSpecSet}
@@ -624,7 +620,7 @@ function create$4 (Ctor) {
624
620
  };
625
621
  }
626
622
 
627
- /* globals DOMQuad */
623
+ /* globals DOMQuad -- Polyfills */
628
624
 
629
625
  /**
630
626
  * @type {import('typeson').TypeSpecSet}
@@ -646,7 +642,7 @@ const domquad = {
646
642
  }
647
643
  };
648
644
 
649
- /* globals DOMRect, DOMRectReadOnly */
645
+ /* globals DOMRect, DOMRectReadOnly -- Polyfills */
650
646
 
651
647
  /**
652
648
  * @type {import('typeson').TypeSpecSet}
@@ -719,8 +715,7 @@ const error = {
719
715
  }
720
716
  };
721
717
 
722
- /* globals InternalError */
723
- /* eslint-env browser, node */
718
+ /* globals InternalError -- Optional */
724
719
 
725
720
  /**
726
721
  * @type {import('typeson').TypeSpecSet}
@@ -811,7 +806,7 @@ function create$2 (Ctor) {
811
806
  };
812
807
  }
813
808
 
814
- /* globals XMLHttpRequest, File, FileReader */
809
+ /* globals XMLHttpRequest, FileReader -- Polyfills */
815
810
 
816
811
  /**
817
812
  * @type {import('typeson').TypeSpecSet}
@@ -855,7 +850,9 @@ const file = {
855
850
  reader.addEventListener('load', function () {
856
851
  resolve({
857
852
  type: f.type,
858
- stringContents: reader.result,
853
+ stringContents: arraybuffer2string(
854
+ /** @type {ArrayBuffer} */ (reader.result)
855
+ ),
859
856
  name: f.name,
860
857
  lastModified: f.lastModified
861
858
  });
@@ -865,7 +862,9 @@ const file = {
865
862
  reader.addEventListener('error', function () {
866
863
  reject(reader.error);
867
864
  });
868
- reader.readAsBinaryString(f);
865
+ // eslint-disable-next-line @stylistic/max-len -- Long
866
+ // eslint-disable-next-line unicorn/prefer-blob-reading-methods -- Too new?
867
+ reader.readAsArrayBuffer(f);
869
868
  });
870
869
  }
871
870
  }
@@ -894,7 +893,7 @@ const filelist = {
894
893
  * Set private properties and length.
895
894
  */
896
895
  constructor () {
897
- // eslint-disable-next-line prefer-rest-params
896
+ // eslint-disable-next-line prefer-rest-params -- API
898
897
  this._files = arguments[0];
899
898
  this.length = this._files.length;
900
899
  }
@@ -905,12 +904,12 @@ const filelist = {
905
904
  item (index) {
906
905
  return this._files[index];
907
906
  }
908
- /* eslint-disable class-methods-use-this */
907
+ /* eslint-disable class-methods-use-this -- Not needed */
909
908
  /**
910
909
  * @returns {"FileList"}
911
910
  */
912
911
  get [Symbol.toStringTag] () {
913
- /* eslint-enable class-methods-use-this */
912
+ /* eslint-enable class-methods-use-this -- Not needed */
914
913
  return 'FileList';
915
914
  }
916
915
  }
@@ -919,7 +918,7 @@ const filelist = {
919
918
  }
920
919
  };
921
920
 
922
- /* globals document, OffscreenCanvas, createImageBitmap */
921
+ /* globals document, OffscreenCanvas, createImageBitmap -- Polyfills */
923
922
  // `ImageBitmap` is browser / DOM specific. It also can only work
924
923
  // same-domain (or CORS)
925
924
 
@@ -1002,7 +1001,7 @@ const imagebitmap = {
1002
1001
  }
1003
1002
  };
1004
1003
 
1005
- /* globals ImageData */
1004
+ /* globals ImageData -- Polyfills */
1006
1005
  // `ImageData` is browser / DOM specific (though `node-canvas` has it
1007
1006
  // available on `Canvas`).
1008
1007
 
@@ -1160,7 +1159,7 @@ const nonbuiltinIgnore = {
1160
1159
 
1161
1160
  // This module is for objectified primitives (such as `new Number(3)` or
1162
1161
  // `new String("foo")`)
1163
- /* eslint-disable no-new-wrappers, unicorn/new-for-builtins */
1162
+ /* eslint-disable no-new-wrappers, unicorn/new-for-builtins -- Deliberate */
1164
1163
 
1165
1164
  /**
1166
1165
  * @type {import('typeson').TypeSpecSet}
@@ -1180,7 +1179,10 @@ const primitiveObjects = {
1180
1179
  return toStringTag(x) === 'Boolean' &&
1181
1180
  typeof x === 'object';
1182
1181
  },
1183
- replace: Boolean, // convert to primitive boolean
1182
+ replace (o) {
1183
+ // convert to primitive boolean
1184
+ return o.valueOf();
1185
+ },
1184
1186
  revive (b) {
1185
1187
  // Revive to an objectified Boolean
1186
1188
  return new Boolean(b);
@@ -1263,8 +1265,6 @@ const set = {
1263
1265
  }
1264
1266
  };
1265
1267
 
1266
- /* eslint-env browser, node */
1267
-
1268
1268
  // Support all kinds of typed arrays (views of ArrayBuffers)
1269
1269
 
1270
1270
  /**
@@ -1331,8 +1331,6 @@ if (typeof Int8Array === 'function') {
1331
1331
  ].forEach((TypedArray) => create$1(TypedArray));
1332
1332
  }
1333
1333
 
1334
- /* eslint-env browser, node */
1335
-
1336
1334
  /**
1337
1335
  * @type {import('typeson').TypeSpecSet}
1338
1336
  */