typeson-registry 2.0.0 → 3.0.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.
Files changed (62) hide show
  1. package/dist/index.js +88 -72
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.min.js +1 -1
  4. package/dist/index.min.js.map +1 -1
  5. package/dist/index.umd.js +73 -68
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/index.umd.min.js +1 -1
  8. package/dist/index.umd.min.js.map +1 -1
  9. package/dist/presets/array-nonindex-keys.umd.js.map +1 -1
  10. package/dist/presets/builtin.umd.js +1 -1
  11. package/dist/presets/builtin.umd.js.map +1 -1
  12. package/dist/presets/postmessage.umd.js +1 -1
  13. package/dist/presets/postmessage.umd.js.map +1 -1
  14. package/dist/presets/socketio.umd.js +1 -1
  15. package/dist/presets/socketio.umd.js.map +1 -1
  16. package/dist/presets/sparse-undefined.umd.js.map +1 -1
  17. package/dist/presets/special-numbers.umd.js.map +1 -1
  18. package/dist/presets/structured-cloning-throwing.umd.js +1 -1
  19. package/dist/presets/structured-cloning-throwing.umd.js.map +1 -1
  20. package/dist/presets/structured-cloning.umd.js +1 -1
  21. package/dist/presets/structured-cloning.umd.js.map +1 -1
  22. package/dist/presets/undef.umd.js.map +1 -1
  23. package/dist/presets/universal.umd.js +1 -1
  24. package/dist/presets/universal.umd.js.map +1 -1
  25. package/dist/types/arraybuffer.umd.js.map +1 -1
  26. package/dist/types/bigint-object.umd.js +1 -1
  27. package/dist/types/bigint-object.umd.js.map +1 -1
  28. package/dist/types/bigint.umd.js +1 -1
  29. package/dist/types/bigint.umd.js.map +1 -1
  30. package/dist/types/blob.umd.js.map +1 -1
  31. package/dist/types/cloneable.umd.js.map +1 -1
  32. package/dist/types/cryptokey.umd.js.map +1 -1
  33. package/dist/types/dataview.umd.js.map +1 -1
  34. package/dist/types/date.umd.js.map +1 -1
  35. package/dist/types/error.umd.js.map +1 -1
  36. package/dist/types/errors.umd.js +1 -1
  37. package/dist/types/errors.umd.js.map +1 -1
  38. package/dist/types/file.umd.js.map +1 -1
  39. package/dist/types/filelist.umd.js.map +1 -1
  40. package/dist/types/imagebitmap.umd.js.map +1 -1
  41. package/dist/types/imagedata.umd.js.map +1 -1
  42. package/dist/types/infinity.umd.js.map +1 -1
  43. package/dist/types/intl-types.umd.js.map +1 -1
  44. package/dist/types/map.umd.js.map +1 -1
  45. package/dist/types/nan.umd.js.map +1 -1
  46. package/dist/types/negative-infinity.umd.js.map +1 -1
  47. package/dist/types/nonbuiltin-ignore.umd.js.map +1 -1
  48. package/dist/types/primitive-objects.umd.js +1 -1
  49. package/dist/types/primitive-objects.umd.js.map +1 -1
  50. package/dist/types/regexp.umd.js.map +1 -1
  51. package/dist/types/resurrectable.umd.js.map +1 -1
  52. package/dist/types/set.umd.js.map +1 -1
  53. package/dist/types/typed-arrays-socketio.umd.js +1 -1
  54. package/dist/types/typed-arrays-socketio.umd.js.map +1 -1
  55. package/dist/types/typed-arrays.umd.js +1 -1
  56. package/dist/types/typed-arrays.umd.js.map +1 -1
  57. package/dist/types/undef.umd.js.map +1 -1
  58. package/dist/types/user-object.umd.js.map +1 -1
  59. package/package.json +20 -20
  60. package/polyfills/createObjectURL.js +3 -3
  61. package/polyfills/createObjectURL.umd.js +1 -1
  62. package/polyfills/createObjectURL.umd.js.map +1 -1
package/dist/index.js CHANGED
@@ -119,7 +119,7 @@ const bigintObject = {
119
119
  test (x) {
120
120
  return typeof x === 'object' && hasConstructorOf(x, BigInt);
121
121
  },
122
- replace (n) { return String(n); },
122
+ replace: String,
123
123
  revive (s) {
124
124
  // Filed this to avoid error: https://github.com/eslint/eslint/issues/11810
125
125
  // eslint-disable-next-line no-new-object
@@ -135,8 +135,8 @@ const bigint = {
135
135
  test (x) {
136
136
  return typeof x === 'bigint';
137
137
  },
138
- replace (n) { return String(n); },
139
- revive (s) { return BigInt(s); }
138
+ replace: String,
139
+ revive: BigInt
140
140
  }
141
141
  };
142
142
 
@@ -408,31 +408,34 @@ const error = {
408
408
  }
409
409
  };
410
410
 
411
- /* eslint-env browser, node */
412
-
413
- /* c8 ignore next */
414
- const _global$2 = typeof self === 'undefined' ? global : self;
411
+ /* globals InternalError */
415
412
 
416
413
  const errors = {};
417
- // Comprises all built-in errors.
414
+
415
+ // JS standard
418
416
  [
419
- 'TypeError',
420
- 'RangeError',
421
- 'SyntaxError',
422
- 'ReferenceError',
423
- 'EvalError',
424
- 'URIError',
425
- 'InternalError' // non-standard
426
- ].forEach((errName) => {
427
- const Cnstrctr = _global$2[errName];
428
- if (Cnstrctr) {
429
- errors[errName.toLowerCase()] = {
430
- test (x) { return hasConstructorOf(x, Cnstrctr); },
431
- replace (e) { return e.message; },
432
- revive (message) { return new Cnstrctr(message); }
433
- };
434
- }
435
- });
417
+ TypeError, RangeError, SyntaxError, ReferenceError, EvalError, URIError
418
+ ].forEach((error) => create$2(error));
419
+
420
+ /* c8 ignore next 2 */
421
+ // @ts-ignore Non-standard
422
+ typeof InternalError === 'function' && create$2(InternalError);
423
+
424
+ /**
425
+ * Comprises all built-in errors.
426
+ * @param {
427
+ * TypeError|RangeError|SyntaxError|ReferenceError|EvalError|URIError|
428
+ * InternalError
429
+ * } Ctor
430
+ * @returns {void}
431
+ */
432
+ function create$2 (Ctor) {
433
+ errors[Ctor.name.toLowerCase()] = {
434
+ test (x) { return hasConstructorOf(x, Ctor); },
435
+ replace (e) { return e.message; },
436
+ revive (message) { return new Ctor(message); }
437
+ };
438
+ }
436
439
 
437
440
  /* globals XMLHttpRequest, File, FileReader */
438
441
 
@@ -710,7 +713,7 @@ const primitiveObjects = {
710
713
  test (x) {
711
714
  return toStringTag(x) === 'String' && typeof x === 'object';
712
715
  },
713
- replace (s) { return String(s); }, // convert to primitive string
716
+ replace: String, // convert to primitive string
714
717
  revive (s) { return new String(s); } // Revive to an objectified string
715
718
  },
716
719
  // Boolean Object (not primitive boolean which need no type spec)
@@ -719,7 +722,7 @@ const primitiveObjects = {
719
722
  return toStringTag(x) === 'Boolean' &&
720
723
  typeof x === 'object';
721
724
  },
722
- replace (b) { return Boolean(b); }, // convert to primitive boolean
725
+ replace: Boolean, // convert to primitive boolean
723
726
  revive (b) {
724
727
  // Revive to an objectified Boolean
725
728
  return new Boolean(b);
@@ -730,7 +733,7 @@ const primitiveObjects = {
730
733
  test (x) {
731
734
  return toStringTag(x) === 'Number' && typeof x === 'object';
732
735
  },
733
- replace (n) { return Number(n); }, // convert to primitive number
736
+ replace: Number, // convert to primitive number
734
737
  revive (n) { return new Number(n); } // Revive to an objectified number
735
738
  }
736
739
  };
@@ -786,30 +789,20 @@ const set = {
786
789
 
787
790
  /* eslint-env browser, node */
788
791
 
789
- /* c8 ignore next */
790
- const _global$1 = typeof self === 'undefined' ? global : self;
791
-
792
792
  // Support all kinds of typed arrays (views of ArrayBuffers)
793
793
  const typedArraysSocketIO = {};
794
- [
795
- 'Int8Array',
796
- 'Uint8Array',
797
- 'Uint8ClampedArray',
798
- 'Int16Array',
799
- 'Uint16Array',
800
- 'Int32Array',
801
- 'Uint32Array',
802
- 'Float32Array',
803
- 'Float64Array'
804
- ].forEach(function (typeName) {
805
- const arrType = typeName;
806
- const TypedArray = _global$1[typeName];
807
- /* c8 ignore next 3 */
808
- if (!TypedArray) {
809
- return;
810
- }
794
+
795
+ /**
796
+ * @param {
797
+ * Int8Array|Uint8Array|Uint8ClampedArray|Int16Array|Uint16Array|Int32Array|
798
+ * Uint32Array|Float32Array|Float64Array
799
+ * } TypedArray
800
+ * @returns {void}
801
+ */
802
+ function create$1 (TypedArray) {
803
+ const typeName = TypedArray.name;
811
804
  typedArraysSocketIO[typeName.toLowerCase()] = {
812
- test (x) { return toStringTag(x) === arrType; },
805
+ test (x) { return toStringTag(x) === typeName; },
813
806
  replace (a) {
814
807
  return (a.byteOffset === 0 &&
815
808
  a.byteLength === a.buffer.byteLength
@@ -832,33 +825,40 @@ const typedArraysSocketIO = {};
832
825
  : buf;
833
826
  }
834
827
  };
835
- });
828
+ }
836
829
 
837
- /* eslint-env browser, node */
830
+ if (typeof Int8Array === 'function') {
831
+ // Those constructors are added in ES6 as a group.
832
+ // If we have Int8Array, we can assume the rest also exists.
833
+
834
+ [
835
+ Int8Array,
836
+ Uint8Array,
837
+ Uint8ClampedArray,
838
+ Int16Array,
839
+ Uint16Array,
840
+ Int32Array,
841
+ Uint32Array,
842
+ Float32Array,
843
+ Float64Array
844
+ ].forEach((TypedArray) => create$1(TypedArray));
845
+ }
838
846
 
839
- /* c8 ignore next */
840
- const _global = typeof self === 'undefined' ? global : self;
847
+ /* eslint-env browser, node */
841
848
 
842
849
  const typedArrays = {};
843
- [
844
- 'Int8Array',
845
- 'Uint8Array',
846
- 'Uint8ClampedArray',
847
- 'Int16Array',
848
- 'Uint16Array',
849
- 'Int32Array',
850
- 'Uint32Array',
851
- 'Float32Array',
852
- 'Float64Array'
853
- ].forEach(function (typeName) {
854
- const arrType = typeName;
855
- const TypedArray = _global[arrType];
856
- /* c8 ignore next 3 */
857
- if (!TypedArray) {
858
- return;
859
- }
850
+
851
+ /**
852
+ * @param {
853
+ * Int8Array|Uint8Array|Uint8ClampedArray|Int16Array|Uint16Array|Int32Array|
854
+ * Uint32Array|Float32Array|Float64Array
855
+ * } TypedArray
856
+ * @returns {void}
857
+ */
858
+ function create (TypedArray) {
859
+ const typeName = TypedArray.name;
860
860
  typedArrays[typeName.toLowerCase()] = {
861
- test (x) { return toStringTag(x) === arrType; },
861
+ test (x) { return toStringTag(x) === typeName; },
862
862
  replace ({buffer, byteOffset, length: l}, stateObj) {
863
863
  if (!stateObj.buffers) {
864
864
  stateObj.buffers = [];
@@ -889,7 +889,23 @@ const typedArrays = {};
889
889
  return new TypedArray(buffer, byteOffset, len);
890
890
  }
891
891
  };
892
- });
892
+ }
893
+
894
+ if (typeof Int8Array === 'function') {
895
+ // Those constructors are added in ES6 as a group.
896
+ // If we have Int8Array, we can assume the rest also exists.
897
+ [
898
+ Int8Array,
899
+ Uint8Array,
900
+ Uint8ClampedArray,
901
+ Int16Array,
902
+ Uint16Array,
903
+ Int32Array,
904
+ Uint32Array,
905
+ Float32Array,
906
+ Float64Array
907
+ ].forEach((TypedArray) => create(TypedArray));
908
+ }
893
909
 
894
910
  // This does not preserve `undefined` in sparse arrays; see the `undef`
895
911