@math.gl/types 4.0.0-alpha.1 → 4.0.0-alpha.2

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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * TypeScript type covering all typed arrays
3
+ */
4
+ export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
5
+ export declare type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
6
+ /**
7
+ * TypeScript type covering all typed arrays and classic arrays consisting of numbers
8
+ */
9
+ export declare type NumericArray = TypedArray | number[];
10
+ /**
11
+ * TypeScript type covering all typed arrays and classic arrays consisting of numbers
12
+ * @note alias for NumericArray
13
+ */
14
+ export declare type NumberArray = NumericArray;
15
+ //# sourceMappingURL=array-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"array-types.d.ts","sourceRoot":"","sources":["../src/array-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,UAAU,GAClB,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AAMjB,oBAAY,qBAAqB,GAC7B,oBAAoB,GACpB,qBAAqB,GACrB,4BAA4B,GAC5B,qBAAqB,GACrB,sBAAsB,GACtB,qBAAqB,GACrB,sBAAsB,GACtB,uBAAuB,GACvB,uBAAuB,CAAC;AAE5B;;GAEG;AACH,oBAAY,YAAY,GAAG,UAAU,GAAG,MAAM,EAAE,CAAC;AAEjD;;;GAGG;AACH,oBAAY,WAAW,GAAG,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=array-types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"number-array.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"array-types.js"}
package/dist/index.cjs CHANGED
@@ -2,6 +2,10 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
5
9
  var __copyProps = (to, from, except, desc) => {
6
10
  if (from && typeof from === "object" || typeof from === "function") {
7
11
  for (let key of __getOwnPropNames(from))
@@ -14,4 +18,19 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
14
18
 
15
19
  // src/index.ts
16
20
  var src_exports = {};
21
+ __export(src_exports, {
22
+ isNumericArray: () => isNumericArray,
23
+ isTypedArray: () => isTypedArray
24
+ });
17
25
  module.exports = __toCommonJS(src_exports);
26
+
27
+ // src/is-array.ts
28
+ function isTypedArray(value) {
29
+ return ArrayBuffer.isView(value) && !(value instanceof DataView) ? value : null;
30
+ }
31
+ function isNumericArray(value) {
32
+ if (Array.isArray(value)) {
33
+ return value.length === 0 || typeof value[0] === "number" ? value : null;
34
+ }
35
+ return isTypedArray(value);
36
+ }
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { TypedArray, NumberArray, NumericArray } from './number-array';
1
+ export type { TypedArray, TypedArrayConstructor, NumericArray, NumberArray } from './array-types';
2
+ export { isTypedArray, isNumericArray } from './is-array';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,WAAW,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,UAAU,EAAE,qBAAqB,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AAChG,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { TypedArray, NumberArray, NumericArray } from "./number-array.js";
1
+ export { isTypedArray, isNumericArray } from "./is-array.js";
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["TypedArray","NumberArray","NumericArray"],"mappings":"SAAQA,U,EAAYC,W,EAAaC,Y","sourcesContent":["export {TypedArray, NumberArray, NumericArray} from './number-array';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["isTypedArray","isNumericArray"],"mappings":"SACQA,Y,EAAcC,c","sourcesContent":["export type {TypedArray, TypedArrayConstructor, NumericArray, NumberArray} from './array-types';\nexport {isTypedArray, isNumericArray} from './is-array';\n"],"file":"index.js"}
@@ -0,0 +1,14 @@
1
+ import { TypedArray, NumericArray } from './array-types';
2
+ /**
3
+ * Check is an array is a typed array
4
+ * @param value value to be tested
5
+ * @returns input as TypedArray, or null
6
+ */
7
+ export declare function isTypedArray(value: unknown): TypedArray | null;
8
+ /**
9
+ * Check is an array is a numeric array (typed array or array of numbers)
10
+ * @param value value to be tested
11
+ * @returns input as NumericArray, or null
12
+ */
13
+ export declare function isNumericArray(value: unknown): NumericArray | null;
14
+ //# sourceMappingURL=is-array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-array.d.ts","sourceRoot":"","sources":["../src/is-array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAE9D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAKlE"}
@@ -0,0 +1,11 @@
1
+ export function isTypedArray(value) {
2
+ return ArrayBuffer.isView(value) && !(value instanceof DataView) ? value : null;
3
+ }
4
+ export function isNumericArray(value) {
5
+ if (Array.isArray(value)) {
6
+ return value.length === 0 || typeof value[0] === 'number' ? value : null;
7
+ }
8
+
9
+ return isTypedArray(value);
10
+ }
11
+ //# sourceMappingURL=is-array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/is-array.ts"],"names":["isTypedArray","value","ArrayBuffer","isView","DataView","isNumericArray","Array","isArray","length"],"mappings":"AAOA,OAAO,SAASA,YAAT,CAAsBC,KAAtB,EAAyD;AAC9D,SAAOC,WAAW,CAACC,MAAZ,CAAmBF,KAAnB,KAA6B,EAAEA,KAAK,YAAYG,QAAnB,CAA7B,GAA6DH,KAA7D,GAAoF,IAA3F;AACD;AAOD,OAAO,SAASI,cAAT,CAAwBJ,KAAxB,EAA6D;AAClE,MAAIK,KAAK,CAACC,OAAN,CAAcN,KAAd,CAAJ,EAA0B;AACxB,WAAOA,KAAK,CAACO,MAAN,KAAiB,CAAjB,IAAsB,OAAOP,KAAK,CAAC,CAAD,CAAZ,KAAoB,QAA1C,GAAsDA,KAAtD,GAA2E,IAAlF;AACD;;AACD,SAAOD,YAAY,CAACC,KAAD,CAAnB;AACD","sourcesContent":["import {TypedArray, NumericArray} from './array-types';\n\n/**\n * Check is an array is a typed array\n * @param value value to be tested\n * @returns input as TypedArray, or null\n */\nexport function isTypedArray(value: unknown): TypedArray | null {\n return ArrayBuffer.isView(value) && !(value instanceof DataView) ? (value as TypedArray) : null;\n}\n\n/**\n * Check is an array is a numeric array (typed array or array of numbers)\n * @param value value to be tested\n * @returns input as NumericArray, or null\n */\nexport function isNumericArray(value: unknown): NumericArray | null {\n if (Array.isArray(value)) {\n return value.length === 0 || typeof value[0] === 'number' ? (value as number[]) : null;\n }\n return isTypedArray(value);\n}\n"],"file":"is-array.js"}
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "version": "4.0.0-alpha.1",
9
+ "version": "4.0.0-alpha.2",
10
10
  "keywords": [
11
11
  "typescript",
12
12
  "javascript",
@@ -28,5 +28,5 @@
28
28
  "sideEffects": [
29
29
  "./src/bigint.js"
30
30
  ],
31
- "gitHead": "66f872ea615a3ef81431595727cdf58dcadf3670"
31
+ "gitHead": "2e693639e3cf898fee8e323c93efdd07be7c2ca7"
32
32
  }
@@ -4,11 +4,11 @@
4
4
  export type TypedArray =
5
5
  | Int8Array
6
6
  | Uint8Array
7
+ | Uint8ClampedArray
7
8
  | Int16Array
8
9
  | Uint16Array
9
10
  | Int32Array
10
11
  | Uint32Array
11
- | Uint8ClampedArray
12
12
  | Float32Array
13
13
  | Float64Array;
14
14
 
@@ -16,6 +16,17 @@ export type TypedArray =
16
16
  // | BigInt64Array
17
17
  // | BigUint64Array;
18
18
 
19
+ export type TypedArrayConstructor =
20
+ | Int8ArrayConstructor
21
+ | Uint8ArrayConstructor
22
+ | Uint8ClampedArrayConstructor
23
+ | Int16ArrayConstructor
24
+ | Uint16ArrayConstructor
25
+ | Int32ArrayConstructor
26
+ | Uint32ArrayConstructor
27
+ | Float32ArrayConstructor
28
+ | Float64ArrayConstructor;
29
+
19
30
  /**
20
31
  * TypeScript type covering all typed arrays and classic arrays consisting of numbers
21
32
  */
@@ -23,5 +34,6 @@ export type NumericArray = TypedArray | number[];
23
34
 
24
35
  /**
25
36
  * TypeScript type covering all typed arrays and classic arrays consisting of numbers
37
+ * @note alias for NumericArray
26
38
  */
27
- export type NumberArray = TypedArray | number[];
39
+ export type NumberArray = NumericArray;
package/src/index.ts CHANGED
@@ -1 +1,2 @@
1
- export {TypedArray, NumberArray, NumericArray} from './number-array';
1
+ export type {TypedArray, TypedArrayConstructor, NumericArray, NumberArray} from './array-types';
2
+ export {isTypedArray, isNumericArray} from './is-array';
@@ -0,0 +1,22 @@
1
+ import {TypedArray, NumericArray} from './array-types';
2
+
3
+ /**
4
+ * Check is an array is a typed array
5
+ * @param value value to be tested
6
+ * @returns input as TypedArray, or null
7
+ */
8
+ export function isTypedArray(value: unknown): TypedArray | null {
9
+ return ArrayBuffer.isView(value) && !(value instanceof DataView) ? (value as TypedArray) : null;
10
+ }
11
+
12
+ /**
13
+ * Check is an array is a numeric array (typed array or array of numbers)
14
+ * @param value value to be tested
15
+ * @returns input as NumericArray, or null
16
+ */
17
+ export function isNumericArray(value: unknown): NumericArray | null {
18
+ if (Array.isArray(value)) {
19
+ return value.length === 0 || typeof value[0] === 'number' ? (value as number[]) : null;
20
+ }
21
+ return isTypedArray(value);
22
+ }
@@ -1,13 +0,0 @@
1
- /**
2
- * TypeScript type covering all typed arrays
3
- */
4
- export type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | Uint8ClampedArray | Float32Array | Float64Array;
5
- /**
6
- * TypeScript type covering all typed arrays and classic arrays consisting of numbers
7
- */
8
- export type NumericArray = TypedArray | number[];
9
- /**
10
- * TypeScript type covering all typed arrays and classic arrays consisting of numbers
11
- */
12
- export type NumberArray = TypedArray | number[];
13
- //# sourceMappingURL=number-array.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"number-array.d.ts","sourceRoot":"","sources":["../src/number-array.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,iBAAiB,GACjB,YAAY,GACZ,YAAY,CAAC;AAMjB;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,MAAM,EAAE,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,EAAE,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=number-array.js.map