@math.gl/types 4.0.1 → 4.1.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.
- package/dist/array-types.d.ts +51 -3
- package/dist/array-types.js +3 -0
- package/dist/bigint.js +3 -0
- package/dist/bounds-types.d.ts +10 -0
- package/dist/bounds-types.js +16 -0
- package/dist/index.cjs +8 -4
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -1
- package/dist/is-array.d.ts +11 -5
- package/dist/is-array.js +18 -7
- package/package.json +2 -2
- package/src/array-types.ts +64 -3
- package/src/bigint.ts +4 -0
- package/src/bounds-types.ts +29 -0
- package/src/index.ts +23 -2
- package/src/is-array.ts +22 -9
package/dist/array-types.d.ts
CHANGED
|
@@ -8,7 +8,55 @@ export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor
|
|
|
8
8
|
*/
|
|
9
9
|
export type NumericArray = TypedArray | number[];
|
|
10
10
|
/**
|
|
11
|
-
* TypeScript type
|
|
12
|
-
* @note
|
|
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 =
|
|
14
|
+
export type NumberArray = number[];
|
|
15
|
+
/** Array with exactly 1 number */
|
|
16
|
+
export type NumberArray1 = [number];
|
|
17
|
+
/** Array with exactly 2 numbers */
|
|
18
|
+
export type NumberArray2 = [number, number];
|
|
19
|
+
/** Array with exactly 3 numbers */
|
|
20
|
+
export type NumberArray3 = [number, number, number];
|
|
21
|
+
/** Array with exactly 4 numbers */
|
|
22
|
+
export type NumberArray4 = [number, number, number, number];
|
|
23
|
+
/** Array with exactly 6 numbers */
|
|
24
|
+
export type NumberArray6 = [number, number, number, number, number, number];
|
|
25
|
+
/** Array with exactly 8 numbers */
|
|
26
|
+
export type NumberArray8 = [number, number, number, number, number, number, number, number];
|
|
27
|
+
/** Array with exactly 9 numbers */
|
|
28
|
+
export type NumberArray9 = [number, number, number, number, number, number, number, number, number];
|
|
29
|
+
/** Array with exactly 12 numbers */
|
|
30
|
+
export type NumberArray12 = [
|
|
31
|
+
number,
|
|
32
|
+
number,
|
|
33
|
+
number,
|
|
34
|
+
number,
|
|
35
|
+
number,
|
|
36
|
+
number,
|
|
37
|
+
number,
|
|
38
|
+
number,
|
|
39
|
+
number,
|
|
40
|
+
number,
|
|
41
|
+
number,
|
|
42
|
+
number
|
|
43
|
+
];
|
|
44
|
+
/** Array with exactly 16 numbers */
|
|
45
|
+
export type NumberArray16 = [
|
|
46
|
+
number,
|
|
47
|
+
number,
|
|
48
|
+
number,
|
|
49
|
+
number,
|
|
50
|
+
number,
|
|
51
|
+
number,
|
|
52
|
+
number,
|
|
53
|
+
number,
|
|
54
|
+
number,
|
|
55
|
+
number,
|
|
56
|
+
number,
|
|
57
|
+
number,
|
|
58
|
+
number,
|
|
59
|
+
number,
|
|
60
|
+
number,
|
|
61
|
+
number
|
|
62
|
+
];
|
package/dist/array-types.js
CHANGED
package/dist/bigint.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** 2 dimensional bounds [[minX, minY], [maxX, maxY]] */
|
|
2
|
+
export type Bounds2D = [[number, number], [number, number]];
|
|
3
|
+
/** 3 dimensional bounds [[minX, minY, minZ], [maxX, maxY, maxZ]] */
|
|
4
|
+
export type Bounds3D = [[number, number, number], [number, number, number]];
|
|
5
|
+
/** 2 or 3 dimensional bounds [[minX, minY], [maxX, maxY]] or [[minX, minY, minZ], [maxX, maxY, maxZ]] */
|
|
6
|
+
export type Bounds = [[number, number], [number, number]] | [[number, number, number], [number, number, number]];
|
|
7
|
+
/** Checks if a `Bounds` is a `Bounds2D` */
|
|
8
|
+
export declare function isBounds2D(bounds: Bounds): bounds is Bounds2D;
|
|
9
|
+
/** Accepts 2D and 3D bounds and returns a 2D bound, truncating 3D dimension if necessary */
|
|
10
|
+
export declare function getBounds2D(bounds: Bounds): Bounds2D;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/** Checks if a `Bounds` is a `Bounds2D` */
|
|
5
|
+
export function isBounds2D(bounds) {
|
|
6
|
+
return bounds.length === 2;
|
|
7
|
+
}
|
|
8
|
+
/** Accepts 2D and 3D bounds and returns a 2D bound, truncating 3D dimension if necessary */
|
|
9
|
+
export function getBounds2D(bounds) {
|
|
10
|
+
return isBounds2D(bounds)
|
|
11
|
+
? bounds
|
|
12
|
+
: [
|
|
13
|
+
[bounds[0][0], bounds[0][1]],
|
|
14
|
+
[bounds[1][0], bounds[1][1]]
|
|
15
|
+
];
|
|
16
|
+
}
|
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
|
});
|
|
@@ -26,12 +27,15 @@ module.exports = __toCommonJS(dist_exports);
|
|
|
26
27
|
|
|
27
28
|
// dist/is-array.js
|
|
28
29
|
function isTypedArray(value) {
|
|
29
|
-
return ArrayBuffer.isView(value) && !(value instanceof DataView)
|
|
30
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
30
31
|
}
|
|
31
|
-
function
|
|
32
|
+
function isNumberArray(value) {
|
|
32
33
|
if (Array.isArray(value)) {
|
|
33
|
-
return value.length === 0 || typeof value[0] === "number"
|
|
34
|
+
return value.length === 0 || typeof value[0] === "number";
|
|
34
35
|
}
|
|
35
|
-
return
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
function isNumericArray(value) {
|
|
39
|
+
return isTypedArray(value) || isNumberArray(value);
|
|
36
40
|
}
|
|
37
41
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["index.js", "is-array.js"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;
|
|
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,2 +1,3 @@
|
|
|
1
|
-
export type { TypedArray, TypedArrayConstructor, NumericArray, NumberArray } from "./array-types.js";
|
|
2
|
-
export { isTypedArray, isNumericArray } from "./is-array.js";
|
|
1
|
+
export type { TypedArray, TypedArrayConstructor, NumericArray, NumberArray, NumberArray1, NumberArray2, NumberArray3, NumberArray4, NumberArray6, NumberArray8, NumberArray9, NumberArray12, NumberArray16 } from "./array-types.js";
|
|
2
|
+
export { isTypedArray, isNumberArray, isNumericArray } from "./is-array.js";
|
|
3
|
+
export type { Bounds, Bounds2D, Bounds3D } from "./bounds-types.js";
|
package/dist/index.js
CHANGED
package/dist/is-array.d.ts
CHANGED
|
@@ -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
|
|
5
|
+
* @returns input with type narrowed to TypedArray, or null
|
|
6
6
|
*/
|
|
7
|
-
export declare function isTypedArray(value: unknown):
|
|
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
|
|
17
|
+
* @returns input with type narrowed to NumericArray, or null
|
|
12
18
|
*/
|
|
13
|
-
export declare function isNumericArray(value: unknown):
|
|
19
|
+
export declare function isNumericArray(value: unknown): value is NumericArray;
|
package/dist/is-array.js
CHANGED
|
@@ -1,19 +1,30 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
/**
|
|
2
5
|
* Check is an array is a typed array
|
|
3
6
|
* @param value value to be tested
|
|
4
|
-
* @returns input
|
|
7
|
+
* @returns input with type narrowed to TypedArray, or null
|
|
5
8
|
*/
|
|
6
9
|
export function isTypedArray(value) {
|
|
7
|
-
return ArrayBuffer.isView(value) && !(value instanceof DataView)
|
|
10
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
|
-
* Check is an array is
|
|
13
|
+
* Check is an array is an array of numbers)
|
|
11
14
|
* @param value value to be tested
|
|
12
|
-
* @returns input
|
|
15
|
+
* @returns input with type narrowed to NumberArray, or null
|
|
13
16
|
*/
|
|
14
|
-
export function
|
|
17
|
+
export function isNumberArray(value) {
|
|
15
18
|
if (Array.isArray(value)) {
|
|
16
|
-
return value.length === 0 || typeof value[0] === 'number'
|
|
19
|
+
return value.length === 0 || typeof value[0] === 'number';
|
|
17
20
|
}
|
|
18
|
-
return
|
|
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);
|
|
19
30
|
}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
|
-
"version": "4.0.
|
|
9
|
+
"version": "4.1.0-alpha.2",
|
|
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": "59eb434870991d06aecff5b1dee38078af0ca447"
|
|
39
39
|
}
|
package/src/array-types.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* TypeScript type covering all typed arrays
|
|
3
7
|
*/
|
|
@@ -33,7 +37,64 @@ export type TypedArrayConstructor =
|
|
|
33
37
|
export type NumericArray = TypedArray | number[];
|
|
34
38
|
|
|
35
39
|
/**
|
|
36
|
-
* TypeScript type
|
|
37
|
-
* @note
|
|
40
|
+
* TypeScript type for classic arrays consisting of numbers
|
|
41
|
+
* @note Included for completeness / orthogonality, prefer `number[]` in actual use
|
|
38
42
|
*/
|
|
39
|
-
export type NumberArray =
|
|
43
|
+
export type NumberArray = number[];
|
|
44
|
+
|
|
45
|
+
/** Array with exactly 1 number */
|
|
46
|
+
export type NumberArray1 = [number];
|
|
47
|
+
|
|
48
|
+
/** Array with exactly 2 numbers */
|
|
49
|
+
export type NumberArray2 = [number, number];
|
|
50
|
+
|
|
51
|
+
/** Array with exactly 3 numbers */
|
|
52
|
+
export type NumberArray3 = [number, number, number];
|
|
53
|
+
|
|
54
|
+
/** Array with exactly 4 numbers */
|
|
55
|
+
export type NumberArray4 = [number, number, number, number];
|
|
56
|
+
|
|
57
|
+
/** Array with exactly 6 numbers */
|
|
58
|
+
export type NumberArray6 = [number, number, number, number, number, number];
|
|
59
|
+
|
|
60
|
+
/** Array with exactly 8 numbers */
|
|
61
|
+
export type NumberArray8 = [number, number, number, number, number, number, number, number];
|
|
62
|
+
|
|
63
|
+
/** Array with exactly 9 numbers */
|
|
64
|
+
export type NumberArray9 = [number, number, number, number, number, number, number, number, number];
|
|
65
|
+
|
|
66
|
+
/** Array with exactly 12 numbers */
|
|
67
|
+
export type NumberArray12 = [
|
|
68
|
+
number,
|
|
69
|
+
number,
|
|
70
|
+
number,
|
|
71
|
+
number,
|
|
72
|
+
number,
|
|
73
|
+
number,
|
|
74
|
+
number,
|
|
75
|
+
number,
|
|
76
|
+
number,
|
|
77
|
+
number,
|
|
78
|
+
number,
|
|
79
|
+
number
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
/** Array with exactly 16 numbers */
|
|
83
|
+
export type NumberArray16 = [
|
|
84
|
+
number,
|
|
85
|
+
number,
|
|
86
|
+
number,
|
|
87
|
+
number,
|
|
88
|
+
number,
|
|
89
|
+
number,
|
|
90
|
+
number,
|
|
91
|
+
number,
|
|
92
|
+
number,
|
|
93
|
+
number,
|
|
94
|
+
number,
|
|
95
|
+
number,
|
|
96
|
+
number,
|
|
97
|
+
number,
|
|
98
|
+
number,
|
|
99
|
+
number
|
|
100
|
+
];
|
package/src/bigint.ts
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/** 2 dimensional bounds [[minX, minY], [maxX, maxY]] */
|
|
6
|
+
export type Bounds2D = [[number, number], [number, number]];
|
|
7
|
+
|
|
8
|
+
/** 3 dimensional bounds [[minX, minY, minZ], [maxX, maxY, maxZ]] */
|
|
9
|
+
export type Bounds3D = [[number, number, number], [number, number, number]];
|
|
10
|
+
|
|
11
|
+
/** 2 or 3 dimensional bounds [[minX, minY], [maxX, maxY]] or [[minX, minY, minZ], [maxX, maxY, maxZ]] */
|
|
12
|
+
export type Bounds =
|
|
13
|
+
| [[number, number], [number, number]]
|
|
14
|
+
| [[number, number, number], [number, number, number]];
|
|
15
|
+
|
|
16
|
+
/** Checks if a `Bounds` is a `Bounds2D` */
|
|
17
|
+
export function isBounds2D(bounds: Bounds): bounds is Bounds2D {
|
|
18
|
+
return bounds.length === 2;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Accepts 2D and 3D bounds and returns a 2D bound, truncating 3D dimension if necessary */
|
|
22
|
+
export function getBounds2D(bounds: Bounds): Bounds2D {
|
|
23
|
+
return isBounds2D(bounds)
|
|
24
|
+
? bounds
|
|
25
|
+
: [
|
|
26
|
+
[bounds[0][0], bounds[0][1]],
|
|
27
|
+
[bounds[1][0], bounds[1][1]]
|
|
28
|
+
];
|
|
29
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export type {
|
|
6
|
+
TypedArray,
|
|
7
|
+
TypedArrayConstructor,
|
|
8
|
+
NumericArray,
|
|
9
|
+
NumberArray,
|
|
10
|
+
NumberArray1,
|
|
11
|
+
NumberArray2,
|
|
12
|
+
NumberArray3,
|
|
13
|
+
NumberArray4,
|
|
14
|
+
NumberArray6,
|
|
15
|
+
NumberArray8,
|
|
16
|
+
NumberArray9,
|
|
17
|
+
NumberArray12,
|
|
18
|
+
NumberArray16
|
|
19
|
+
} from './array-types';
|
|
20
|
+
|
|
21
|
+
export {isTypedArray, isNumberArray, isNumericArray} from './is-array';
|
|
22
|
+
|
|
23
|
+
export type {Bounds, Bounds2D, Bounds3D} from './bounds-types';
|
package/src/is-array.ts
CHANGED
|
@@ -1,22 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {TypedArray, NumericArray, NumberArray} from './array-types';
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* Check is an array is a typed array
|
|
5
9
|
* @param value value to be tested
|
|
6
|
-
* @returns input
|
|
10
|
+
* @returns input with type narrowed to TypedArray, or null
|
|
7
11
|
*/
|
|
8
|
-
export function isTypedArray(value: unknown):
|
|
9
|
-
return ArrayBuffer.isView(value) && !(value instanceof DataView)
|
|
12
|
+
export function isTypedArray(value: unknown): value is TypedArray {
|
|
13
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
/**
|
|
13
|
-
* Check is an array is
|
|
17
|
+
* Check is an array is an array of numbers)
|
|
14
18
|
* @param value value to be tested
|
|
15
|
-
* @returns input
|
|
19
|
+
* @returns input with type narrowed to NumberArray, or null
|
|
16
20
|
*/
|
|
17
|
-
export function
|
|
21
|
+
export function isNumberArray(value: unknown): value is NumberArray {
|
|
18
22
|
if (Array.isArray(value)) {
|
|
19
|
-
return value.length === 0 || typeof value[0] === 'number'
|
|
23
|
+
return value.length === 0 || typeof value[0] === 'number';
|
|
20
24
|
}
|
|
21
|
-
return
|
|
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);
|
|
22
35
|
}
|