@math.gl/types 4.1.0-alpha.1 → 4.1.0-alpha.3

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.
@@ -8,10 +8,10 @@ export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor
8
8
  */
9
9
  export type NumericArray = TypedArray | number[];
10
10
  /**
11
- * TypeScript type covering all typed arrays and classic arrays consisting of numbers
12
- * @note alias for NumericArray
11
+ * TypeScript type for classic arrays consisting of numbers
12
+ * @note Included for completeness / orthogonality, prefer `number[]` in actual use
13
13
  */
14
- export type NumberArray = TypedArray | number[];
14
+ export type NumberArray = number[];
15
15
  /** Array with exactly 1 number */
16
16
  export type NumberArray1 = [number];
17
17
  /** Array with exactly 2 numbers */
package/dist/index.cjs CHANGED
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  // dist/index.js
20
20
  var dist_exports = {};
21
21
  __export(dist_exports, {
22
+ isNumberArray: () => isNumberArray,
22
23
  isNumericArray: () => isNumericArray,
23
24
  isTypedArray: () => isTypedArray
24
25
  });
@@ -28,10 +29,13 @@ module.exports = __toCommonJS(dist_exports);
28
29
  function isTypedArray(value) {
29
30
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
30
31
  }
31
- function isNumericArray(value) {
32
+ function isNumberArray(value) {
32
33
  if (Array.isArray(value)) {
33
34
  return value.length === 0 || typeof value[0] === "number";
34
35
  }
35
- return isTypedArray(value);
36
+ return false;
37
+ }
38
+ function isNumericArray(value) {
39
+ return isTypedArray(value) || isNumberArray(value);
36
40
  }
37
41
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js", "is-array.js"],
4
- "sourcesContent": ["// math.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { isTypedArray, isNumericArray } from \"./is-array.js\";\n", "// math.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\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) {\n return ArrayBuffer.isView(value) && !(value instanceof DataView);\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) {\n if (Array.isArray(value)) {\n return value.length === 0 || typeof value[0] === 'number';\n }\n return isTypedArray(value);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,SAAS,aAAa,OAAO;AAChC,SAAO,YAAY,OAAO,KAAK,KAAK,EAAE,iBAAiB;AAC3D;AAMO,SAAS,eAAe,OAAO;AAClC,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,WAAO,MAAM,WAAW,KAAK,OAAO,MAAM,OAAO;AAAA,EACrD;AACA,SAAO,aAAa,KAAK;AAC7B;",
4
+ "sourcesContent": ["// math.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { isTypedArray, isNumberArray, isNumericArray } from \"./is-array.js\";\n", "// math.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/**\n * Check is an array is a typed array\n * @param value value to be tested\n * @returns input with type narrowed to TypedArray, or null\n */\nexport function isTypedArray(value) {\n return ArrayBuffer.isView(value) && !(value instanceof DataView);\n}\n/**\n * Check is an array is an array of numbers)\n * @param value value to be tested\n * @returns input with type narrowed to NumberArray, or null\n */\nexport function isNumberArray(value) {\n if (Array.isArray(value)) {\n return value.length === 0 || typeof value[0] === 'number';\n }\n return false;\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 with type narrowed to NumericArray, or null\n */\nexport function isNumericArray(value) {\n return isTypedArray(value) || isNumberArray(value);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,SAAS,aAAa,OAAO;AAChC,SAAO,YAAY,OAAO,KAAK,KAAK,EAAE,iBAAiB;AAC3D;AAMO,SAAS,cAAc,OAAO;AACjC,MAAI,MAAM,QAAQ,KAAK,GAAG;AACtB,WAAO,MAAM,WAAW,KAAK,OAAO,MAAM,OAAO;AAAA,EACrD;AACA,SAAO;AACX;AAMO,SAAS,eAAe,OAAO;AAClC,SAAO,aAAa,KAAK,KAAK,cAAc,KAAK;AACrD;",
6
6
  "names": []
7
7
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export type { TypedArray, TypedArrayConstructor, NumericArray, NumberArray, NumberArray1, NumberArray2, NumberArray3, NumberArray4, NumberArray6, NumberArray8, NumberArray9, NumberArray12, NumberArray16 } from "./array-types.js";
2
- export { isTypedArray, isNumericArray } from "./is-array.js";
2
+ export { isTypedArray, isNumberArray, isNumericArray } from "./is-array.js";
3
3
  export type { Bounds, Bounds2D, Bounds3D } from "./bounds-types.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // math.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- export { isTypedArray, isNumericArray } from "./is-array.js";
4
+ export { isTypedArray, isNumberArray, isNumericArray } from "./is-array.js";
@@ -1,13 +1,19 @@
1
- import { TypedArray, NumericArray } from "./array-types.js";
1
+ import { TypedArray, NumericArray, NumberArray } from "./array-types.js";
2
2
  /**
3
3
  * Check is an array is a typed array
4
4
  * @param value value to be tested
5
- * @returns input as TypedArray, or null
5
+ * @returns input with type narrowed to TypedArray, or null
6
6
  */
7
7
  export declare function isTypedArray(value: unknown): value is TypedArray;
8
+ /**
9
+ * Check is an array is an array of numbers)
10
+ * @param value value to be tested
11
+ * @returns input with type narrowed to NumberArray, or null
12
+ */
13
+ export declare function isNumberArray(value: unknown): value is NumberArray;
8
14
  /**
9
15
  * Check is an array is a numeric array (typed array or array of numbers)
10
16
  * @param value value to be tested
11
- * @returns input as NumericArray, or null
17
+ * @returns input with type narrowed to NumericArray, or null
12
18
  */
13
19
  export declare function isNumericArray(value: unknown): value is NumericArray;
package/dist/is-array.js CHANGED
@@ -4,19 +4,27 @@
4
4
  /**
5
5
  * Check is an array is a typed array
6
6
  * @param value value to be tested
7
- * @returns input as TypedArray, or null
7
+ * @returns input with type narrowed to TypedArray, or null
8
8
  */
9
9
  export function isTypedArray(value) {
10
10
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
11
11
  }
12
12
  /**
13
- * Check is an array is a numeric array (typed array or array of numbers)
13
+ * Check is an array is an array of numbers)
14
14
  * @param value value to be tested
15
- * @returns input as NumericArray, or null
15
+ * @returns input with type narrowed to NumberArray, or null
16
16
  */
17
- export function isNumericArray(value) {
17
+ export function isNumberArray(value) {
18
18
  if (Array.isArray(value)) {
19
19
  return value.length === 0 || typeof value[0] === 'number';
20
20
  }
21
- return isTypedArray(value);
21
+ return false;
22
+ }
23
+ /**
24
+ * Check is an array is a numeric array (typed array or array of numbers)
25
+ * @param value value to be tested
26
+ * @returns input with type narrowed to NumericArray, or null
27
+ */
28
+ export function isNumericArray(value) {
29
+ return isTypedArray(value) || isNumberArray(value);
22
30
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
- "version": "4.1.0-alpha.1",
9
+ "version": "4.1.0-alpha.3",
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": "1a4dbbc6ab46271459d610411a7c644e45135c2c"
38
+ "gitHead": "566d5ec1819367a7d7e98b413eed6f951913c35b"
39
39
  }
@@ -37,10 +37,10 @@ export type TypedArrayConstructor =
37
37
  export type NumericArray = TypedArray | number[];
38
38
 
39
39
  /**
40
- * TypeScript type covering all typed arrays and classic arrays consisting of numbers
41
- * @note alias for NumericArray
40
+ * TypeScript type for classic arrays consisting of numbers
41
+ * @note Included for completeness / orthogonality, prefer `number[]` in actual use
42
42
  */
43
- export type NumberArray = TypedArray | number[];
43
+ export type NumberArray = number[];
44
44
 
45
45
  /** Array with exactly 1 number */
46
46
  export type NumberArray1 = [number];
@@ -23,7 +23,7 @@ export function getBounds2D(bounds: Bounds): Bounds2D {
23
23
  return isBounds2D(bounds)
24
24
  ? bounds
25
25
  : [
26
- [bounds[0][0], bounds[0][1]],
27
- [bounds[1][0], bounds[1][1]]
28
- ];
26
+ [bounds[0][0], bounds[0][1]],
27
+ [bounds[1][0], bounds[1][1]]
28
+ ];
29
29
  }
package/src/index.ts CHANGED
@@ -17,6 +17,7 @@ export type {
17
17
  NumberArray12,
18
18
  NumberArray16
19
19
  } from './array-types';
20
- export {isTypedArray, isNumericArray} from './is-array';
20
+
21
+ export {isTypedArray, isNumberArray, isNumericArray} from './is-array';
21
22
 
22
23
  export type {Bounds, Bounds2D, Bounds3D} from './bounds-types';
package/src/is-array.ts CHANGED
@@ -2,25 +2,34 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
- import {TypedArray, NumericArray} from './array-types';
5
+ import {TypedArray, NumericArray, NumberArray} from './array-types';
6
6
 
7
7
  /**
8
8
  * Check is an array is a typed array
9
9
  * @param value value to be tested
10
- * @returns input as TypedArray, or null
10
+ * @returns input with type narrowed to TypedArray, or null
11
11
  */
12
12
  export function isTypedArray(value: unknown): value is TypedArray {
13
13
  return ArrayBuffer.isView(value) && !(value instanceof DataView);
14
14
  }
15
15
 
16
16
  /**
17
- * Check is an array is a numeric array (typed array or array of numbers)
17
+ * Check is an array is an array of numbers)
18
18
  * @param value value to be tested
19
- * @returns input as NumericArray, or null
19
+ * @returns input with type narrowed to NumberArray, or null
20
20
  */
21
- export function isNumericArray(value: unknown): value is NumericArray {
21
+ export function isNumberArray(value: unknown): value is NumberArray {
22
22
  if (Array.isArray(value)) {
23
23
  return value.length === 0 || typeof value[0] === 'number';
24
24
  }
25
- return isTypedArray(value);
25
+ return false;
26
+ }
27
+
28
+ /**
29
+ * Check is an array is a numeric array (typed array or array of numbers)
30
+ * @param value value to be tested
31
+ * @returns input with type narrowed to NumericArray, or null
32
+ */
33
+ export function isNumericArray(value: unknown): value is NumericArray {
34
+ return isTypedArray(value) || isNumberArray(value);
26
35
  }