@math.gl/types 5.0.0-alpha.12 → 5.0.0-alpha.14
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/float16.d.ts +6 -0
- package/dist/float16.d.ts.map +1 -1
- package/dist/float16.js +9 -0
- package/dist/float16.js.map +1 -1
- package/dist/index.cjs +15 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/is-array.d.ts +2 -0
- package/dist/is-array.d.ts.map +1 -1
- package/dist/is-array.js +5 -0
- package/dist/is-array.js.map +1 -1
- package/dist/typed-array-brand.d.ts +2 -0
- package/dist/typed-array-brand.d.ts.map +1 -0
- package/dist/typed-array-brand.js +10 -0
- package/dist/typed-array-brand.js.map +1 -0
- package/package.json +2 -2
- package/src/float16.ts +10 -0
- package/src/index.ts +3 -2
- package/src/is-array.ts +6 -0
- package/src/typed-array-brand.ts +14 -0
package/dist/float16.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { TypedArrayConstructor } from "./array-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Checks for native Float16Array values, including arrays from other realms.
|
|
4
|
+
* Does not identify Uint16Array binary16 storage as a decoded Float16Array.
|
|
5
|
+
* Does not require a Float16Array constructor in the current realm.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isFloat16Array(value: unknown): value is Float16Array;
|
|
2
8
|
/**
|
|
3
9
|
* The native `Float16Array` constructor exposed by the current JavaScript runtime.
|
|
4
10
|
*
|
package/dist/float16.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"float16.d.ts","sourceRoot":"","sources":["../src/float16.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,qBAAqB,EAAC,yBAAsB;
|
|
1
|
+
{"version":3,"file":"float16.d.ts","sourceRoot":"","sources":["../src/float16.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,qBAAqB,EAAC,yBAAsB;AAGzD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,6BAA6B,EAAE,qBAAqB,GAAG,SAC3C,CAAC;AAE1B;;;;;;GAMG;AACH,wBAAgB,0BAA0B,IAAI,qBAAqB,CAElE;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEjE"}
|
package/dist/float16.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
// math.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import { getTypedArrayName } from "./typed-array-brand.js";
|
|
5
|
+
/**
|
|
6
|
+
* Checks for native Float16Array values, including arrays from other realms.
|
|
7
|
+
* Does not identify Uint16Array binary16 storage as a decoded Float16Array.
|
|
8
|
+
* Does not require a Float16Array constructor in the current realm.
|
|
9
|
+
*/
|
|
10
|
+
export function isFloat16Array(value) {
|
|
11
|
+
return getTypedArrayName(value) === 'Float16Array';
|
|
12
|
+
}
|
|
4
13
|
/**
|
|
5
14
|
* The native `Float16Array` constructor exposed by the current JavaScript runtime.
|
|
6
15
|
*
|
package/dist/float16.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"float16.js","sourceRoot":"","sources":["../src/float16.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;
|
|
1
|
+
{"version":3,"file":"float16.js","sourceRoot":"","sources":["../src/float16.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAG5D,OAAO,EAAC,iBAAiB,EAAC,+BAA4B;AAEtD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,cAAc,CAAC;AACrD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,6BAA6B,GACxC,UAAU,CAAC,YAAY,CAAC;AAE1B;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,6BAA6B,IAAI,WAAW,CAAC;AACtD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,KAAc;IACtD,OAAO,OAAO,CAAC,6BAA6B,IAAI,KAAK,KAAK,6BAA6B,CAAC,CAAC;AAC3F,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -21,14 +21,25 @@ var index_exports = {};
|
|
|
21
21
|
__export(index_exports, {
|
|
22
22
|
NativeFloat16ArrayConstructor: () => NativeFloat16ArrayConstructor,
|
|
23
23
|
getFloat16ArrayConstructor: () => getFloat16ArrayConstructor,
|
|
24
|
+
isFloat16Array: () => isFloat16Array,
|
|
24
25
|
isFloat16ArrayConstructor: () => isFloat16ArrayConstructor,
|
|
25
26
|
isNumberArray: () => isNumberArray,
|
|
26
27
|
isNumericArray: () => isNumericArray,
|
|
27
|
-
isTypedArray: () => isTypedArray
|
|
28
|
+
isTypedArray: () => isTypedArray,
|
|
29
|
+
isUint16Array: () => isUint16Array
|
|
28
30
|
});
|
|
29
31
|
module.exports = __toCommonJS(index_exports);
|
|
30
32
|
|
|
33
|
+
// dist/typed-array-brand.js
|
|
34
|
+
var typedArrayTagGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
|
|
35
|
+
function getTypedArrayName(value) {
|
|
36
|
+
return ArrayBuffer.isView(value) ? typedArrayTagGetter.call(value) : void 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
// dist/is-array.js
|
|
40
|
+
function isUint16Array(value) {
|
|
41
|
+
return getTypedArrayName(value) === "Uint16Array";
|
|
42
|
+
}
|
|
32
43
|
function isTypedArray(value) {
|
|
33
44
|
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
34
45
|
}
|
|
@@ -43,6 +54,9 @@ function isNumericArray(value) {
|
|
|
43
54
|
}
|
|
44
55
|
|
|
45
56
|
// dist/float16.js
|
|
57
|
+
function isFloat16Array(value) {
|
|
58
|
+
return getTypedArrayName(value) === "Float16Array";
|
|
59
|
+
}
|
|
46
60
|
var NativeFloat16ArrayConstructor = globalThis.Float16Array;
|
|
47
61
|
function getFloat16ArrayConstructor() {
|
|
48
62
|
return NativeFloat16ArrayConstructor ?? Uint16Array;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts", "../src/is-array.ts", "../src/float16.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA
|
|
3
|
+
"sources": ["../src/index.ts", "../src/typed-array-brand.ts", "../src/is-array.ts", "../src/float16.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;ACMA,IAAM,sBAAsB,OAAO,yBACjC,OAAO,eAAe,WAAW,SAAS,GAC1C,OAAO,WAAW,EACjB;AAEG,SAAU,kBAAkB,OAAc;AAC9C,SAAO,YAAY,OAAO,KAAK,IAAI,oBAAoB,KAAK,KAAK,IAAI;AACvE;;;ACLM,SAAU,cAAc,OAAc;AAC1C,SAAO,kBAAkB,KAAK,MAAM;AACtC;AAOM,SAAU,aAAa,OAAc;AACzC,SAAO,YAAY,OAAO,KAAK,KAAK,EAAE,iBAAiB;AACzD;AAOM,SAAU,cAAc,OAAc;AAC1C,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,WAAW,KAAK,OAAO,MAAM,CAAC,MAAM;EACnD;AACA,SAAO;AACT;AAOM,SAAU,eAAe,OAAc;AAC3C,SAAO,aAAa,KAAK,KAAK,cAAc,KAAK;AACnD;;;AC5BM,SAAU,eAAe,OAAc;AAC3C,SAAO,kBAAkB,KAAK,MAAM;AACtC;AASO,IAAM,gCACX,WAAW;AASP,SAAU,6BAA0B;AACxC,SAAO,iCAAiC;AAC1C;AASM,SAAU,0BAA0B,OAAc;AACtD,SAAO,QAAQ,iCAAiC,UAAU,6BAA6B;AACzF;",
|
|
5
5
|
"names": []
|
|
6
6
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { TypedArray, TypedArrayConstructor, BigTypedArray, BigTypedArrayConstructor, NumberArray, NumberArray1, NumberArray2, NumberArray3, NumberArray4, NumberArray6, NumberArray8, NumberArray9, NumberArray12, NumberArray16, NumericArray, NumericArray1, NumericArray2, NumericArray3, NumericArray4, NumericArray6, NumericArray8, NumericArray9, NumericArray12, NumericArray16 } from "./array-types.js";
|
|
2
|
-
export { isTypedArray, isNumberArray, isNumericArray } from "./is-array.js";
|
|
3
|
-
export { NativeFloat16ArrayConstructor, getFloat16ArrayConstructor, isFloat16ArrayConstructor } from "./float16.js";
|
|
2
|
+
export { isTypedArray, isUint16Array, isNumberArray, isNumericArray } from "./is-array.js";
|
|
3
|
+
export { NativeFloat16ArrayConstructor, getFloat16ArrayConstructor, isFloat16ArrayConstructor, isFloat16Array } from "./float16.js";
|
|
4
4
|
export type { Bounds, Bounds2D, Bounds3D } from "./bounds-types.js";
|
|
5
5
|
export type { SpheroidParameters } from "./spheroid.js";
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EAEV,UAAU,EACV,qBAAqB,EACrB,aAAa,EACb,wBAAwB,EAExB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EAEb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACf,yBAAsB;AAEvB,OAAO,EAAC,YAAY,EAAE,aAAa,EAAE,cAAc,EAAC,sBAAmB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,YAAY,EAEV,UAAU,EACV,qBAAqB,EACrB,aAAa,EACb,wBAAwB,EAExB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,aAAa,EAEb,YAAY,EACZ,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACf,yBAAsB;AAEvB,OAAO,EAAC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAC,sBAAmB;AACtF,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,cAAc,EACf,qBAAkB;AAEnB,YAAY,EAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAC,0BAAuB;AAE/D,YAAY,EAAC,kBAAkB,EAAC,sBAAmB"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// math.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
-
export { isTypedArray, isNumberArray, isNumericArray } from "./is-array.js";
|
|
5
|
-
export { NativeFloat16ArrayConstructor, getFloat16ArrayConstructor, isFloat16ArrayConstructor } from "./float16.js";
|
|
4
|
+
export { isTypedArray, isUint16Array, isNumberArray, isNumericArray } from "./is-array.js";
|
|
5
|
+
export { NativeFloat16ArrayConstructor, getFloat16ArrayConstructor, isFloat16ArrayConstructor, isFloat16Array } from "./float16.js";
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAgC5D,OAAO,EAAC,YAAY,EAAE,aAAa,EAAE,cAAc,EAAC,sBAAmB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAgC5D,OAAO,EAAC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAC,sBAAmB;AACtF,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,EAC1B,yBAAyB,EACzB,cAAc,EACf,qBAAkB"}
|
package/dist/is-array.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { TypedArray, NumericArray, NumberArray } from "./array-types.js";
|
|
2
|
+
/** Checks for unsigned 16-bit samples, including typed arrays from other realms. */
|
|
3
|
+
export declare function isUint16Array(value: unknown): value is Uint16Array;
|
|
2
4
|
/**
|
|
3
5
|
* Check is an array is a typed array
|
|
4
6
|
* @param value value to be tested
|
package/dist/is-array.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-array.d.ts","sourceRoot":"","sources":["../src/is-array.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,WAAW,EAAC,yBAAsB;
|
|
1
|
+
{"version":3,"file":"is-array.d.ts","sourceRoot":"","sources":["../src/is-array.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,WAAW,EAAC,yBAAsB;AAGpE,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAKlE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAEpE"}
|
package/dist/is-array.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
// math.gl
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
import { getTypedArrayName } from "./typed-array-brand.js";
|
|
5
|
+
/** Checks for unsigned 16-bit samples, including typed arrays from other realms. */
|
|
6
|
+
export function isUint16Array(value) {
|
|
7
|
+
return getTypedArrayName(value) === 'Uint16Array';
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
10
|
* Check is an array is a typed array
|
|
6
11
|
* @param value value to be tested
|
package/dist/is-array.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-array.js","sourceRoot":"","sources":["../src/is-array.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;
|
|
1
|
+
{"version":3,"file":"is-array.js","sourceRoot":"","sources":["../src/is-array.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAG5D,OAAO,EAAC,iBAAiB,EAAC,+BAA4B;AAEtD,oFAAoF;AACpF,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,aAAa,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAc;IACzC,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,YAAY,QAAQ,CAAC,CAAC;AACnE,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC;IAC5D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-array-brand.d.ts","sourceRoot":"","sources":["../src/typed-array-brand.ts"],"names":[],"mappings":"AAWA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEpE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
// Use the intrinsic getter so constructor and Symbol.toStringTag overrides cannot
|
|
5
|
+
// disguise a typed array's element type. It also works for arrays from other realms.
|
|
6
|
+
const typedArrayTagGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
|
|
7
|
+
export function getTypedArrayName(value) {
|
|
8
|
+
return ArrayBuffer.isView(value) ? typedArrayTagGetter.call(value) : undefined;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=typed-array-brand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typed-array-brand.js","sourceRoot":"","sources":["../src/typed-array-brand.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAE5D,kFAAkF;AAClF,qFAAqF;AACrF,MAAM,mBAAmB,GAAG,MAAM,CAAC,wBAAwB,CACzD,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,SAAS,CAAC,EAC3C,MAAM,CAAC,WAAW,CAClB,CAAC,GAAI,CAAC;AAER,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjF,CAAC"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
|
-
"version": "5.0.0-alpha.
|
|
9
|
+
"version": "5.0.0-alpha.14",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"typescript",
|
|
12
12
|
"javascript",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"sideEffects": [
|
|
36
36
|
"./src/bigint.js"
|
|
37
37
|
],
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "c4f1cbdd7fc9136a873efc511356cace8ff0001a"
|
|
39
39
|
}
|
package/src/float16.ts
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {TypedArrayConstructor} from './array-types';
|
|
6
|
+
import {getTypedArrayName} from './typed-array-brand';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Checks for native Float16Array values, including arrays from other realms.
|
|
10
|
+
* Does not identify Uint16Array binary16 storage as a decoded Float16Array.
|
|
11
|
+
* Does not require a Float16Array constructor in the current realm.
|
|
12
|
+
*/
|
|
13
|
+
export function isFloat16Array(value: unknown): value is Float16Array {
|
|
14
|
+
return getTypedArrayName(value) === 'Float16Array';
|
|
15
|
+
}
|
|
6
16
|
|
|
7
17
|
/**
|
|
8
18
|
* The native `Float16Array` constructor exposed by the current JavaScript runtime.
|
package/src/index.ts
CHANGED
|
@@ -32,11 +32,12 @@ export type {
|
|
|
32
32
|
NumericArray16
|
|
33
33
|
} from './array-types';
|
|
34
34
|
|
|
35
|
-
export {isTypedArray, isNumberArray, isNumericArray} from './is-array';
|
|
35
|
+
export {isTypedArray, isUint16Array, isNumberArray, isNumericArray} from './is-array';
|
|
36
36
|
export {
|
|
37
37
|
NativeFloat16ArrayConstructor,
|
|
38
38
|
getFloat16ArrayConstructor,
|
|
39
|
-
isFloat16ArrayConstructor
|
|
39
|
+
isFloat16ArrayConstructor,
|
|
40
|
+
isFloat16Array
|
|
40
41
|
} from './float16';
|
|
41
42
|
|
|
42
43
|
export type {Bounds, Bounds2D, Bounds3D} from './bounds-types';
|
package/src/is-array.ts
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {TypedArray, NumericArray, NumberArray} from './array-types';
|
|
6
|
+
import {getTypedArrayName} from './typed-array-brand';
|
|
7
|
+
|
|
8
|
+
/** Checks for unsigned 16-bit samples, including typed arrays from other realms. */
|
|
9
|
+
export function isUint16Array(value: unknown): value is Uint16Array {
|
|
10
|
+
return getTypedArrayName(value) === 'Uint16Array';
|
|
11
|
+
}
|
|
6
12
|
|
|
7
13
|
/**
|
|
8
14
|
* Check is an array is a typed array
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
// Use the intrinsic getter so constructor and Symbol.toStringTag overrides cannot
|
|
6
|
+
// disguise a typed array's element type. It also works for arrays from other realms.
|
|
7
|
+
const typedArrayTagGetter = Object.getOwnPropertyDescriptor(
|
|
8
|
+
Object.getPrototypeOf(Uint8Array.prototype),
|
|
9
|
+
Symbol.toStringTag
|
|
10
|
+
)!.get!;
|
|
11
|
+
|
|
12
|
+
export function getTypedArrayName(value: unknown): string | undefined {
|
|
13
|
+
return ArrayBuffer.isView(value) ? typedArrayTagGetter.call(value) : undefined;
|
|
14
|
+
}
|