typeson-registry 13.2.0 → 13.2.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.
package/dist/index.d.ts CHANGED
@@ -47,5 +47,4 @@ import structuredCloning from './presets/structured-cloning.js';
47
47
  import undefPreset from './presets/undef.js';
48
48
  import universal from './presets/universal.js';
49
49
  export { arraybuffer, audiodata, bigintObject, bigint, blob, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domquad, domrect, error, errors, file, filelist, imagebitmap, imagedata, infinity, intlTypes, map, nan, negativeInfinity, negativeZero, nonbuiltinIgnore, primitiveObjects, promise, regexp, resurrectable, set, symbol, typedArraysSocketio, typedArrays, undef, userObject, arrayNonindexKeys, builtin, postmessage, socketio, sparseUndefined, specialNumbers, structuredCloningThrowing, structuredCloning, undefPreset, universal };
50
- //# sourceMappingURL=index.d.ts.map
51
- export type * from 'typeson';
50
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -982,6 +982,8 @@ const filelist = {
982
982
  return 'FileList';
983
983
  }
984
984
  }
985
+
986
+ // @ts-ignore Override API
985
987
  return new FileList(o);
986
988
  }
987
989
  }
@@ -1820,6 +1822,34 @@ const expObj = [
1820
1822
  typeof AudioData !== 'undefined' ? audiodata : []
1821
1823
  );
1822
1824
 
1825
+ /**
1826
+ * @param {BufferSource} buffer
1827
+ * @returns {boolean}
1828
+ */
1829
+ function isBufferDetached (buffer) {
1830
+ // Use the standard property if available
1831
+ // @ts-expect-error - More recent API
1832
+ if (typeof buffer.detached === 'boolean') {
1833
+ // @ts-expect-error - More recent API
1834
+ return buffer.detached;
1835
+ }
1836
+ /* c8 ignore next 14 -- Older browsers */
1837
+
1838
+ // Fallback check via byteLength and constructor test
1839
+ if (buffer.byteLength !== 0) {
1840
+ return false;
1841
+ }
1842
+
1843
+ try {
1844
+ // @ts-expect-error Ok
1845
+ // eslint-disable-next-line no-new -- Throwaway
1846
+ new Uint8Array(buffer);
1847
+ return false;
1848
+ } catch {
1849
+ return true;
1850
+ }
1851
+ }
1852
+
1823
1853
  /**
1824
1854
  * @type {import('typeson').Preset}
1825
1855
  */
@@ -1827,13 +1857,11 @@ const structuredCloningThrowing = expObj.concat({
1827
1857
  checkDataCloneException: {
1828
1858
  test (val) {
1829
1859
  // Should also throw with:
1830
- // 1. `IsDetachedBuffer` (a process not called within the
1831
- // ECMAScript spec)
1832
- // 2. `IsCallable` (covered by `typeof === 'function'` or a
1860
+ // 1. `IsCallable` (covered by `typeof === 'function'` or a
1833
1861
  // function's `toStringTag`)
1834
- // 3. internal slots besides [[Prototype]] or [[Extensible]] (e.g.,
1862
+ // 2. internal slots besides [[Prototype]] or [[Extensible]] (e.g.,
1835
1863
  // [[PromiseState]] or [[WeakMapData]])
1836
- // 4. exotic object (e.g., `Proxy`) (unless an `%ObjectPrototype%`
1864
+ // 3. exotic object (e.g., `Proxy`) (unless an `%ObjectPrototype%`
1837
1865
  // intrinsic object) (which does not have default
1838
1866
  // behavior for one or more of the essential internal methods
1839
1867
  // that are limited to the following for non-function objects
@@ -1875,6 +1903,23 @@ const structuredCloningThrowing = expObj.concat({
1875
1903
  // Also in Node `worker_threads` (currently experimental)
1876
1904
  'MessageChannel'
1877
1905
  ].includes(stringTag) ||
1906
+ // 1. `IsDetachedBuffer` (a process not called within the
1907
+ // ECMAScript spec)
1908
+ ([
1909
+ 'ArrayBuffer',
1910
+ 'DataView',
1911
+ 'Int8Array',
1912
+ 'Uint8Array',
1913
+ 'Uint8ClampedArray',
1914
+ 'Int16Array',
1915
+ 'Uint16Array',
1916
+ 'Int32Array',
1917
+ 'Uint32Array',
1918
+ 'Float32Array',
1919
+ 'Float64Array',
1920
+ 'BigInt64Array',
1921
+ 'BigUint64Array'
1922
+ ].includes(stringTag) && isBufferDetached(val)) ||
1878
1923
  /*
1879
1924
  // isClosed is no longer documented
1880
1925
  ((stringTag === 'Blob' || stringTag === 'File') &&