@math.gl/types 4.0.1 → 4.1.0-alpha.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/array-types.d.ts +49 -1
- 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 +2 -2
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -0
- package/dist/is-array.d.ts +2 -2
- package/dist/is-array.js +5 -2
- package/package.json +2 -2
- package/src/array-types.ts +62 -1
- package/src/bigint.ts +4 -0
- package/src/bounds-types.ts +29 -0
- package/src/index.ts +21 -1
- package/src/is-array.ts +8 -4
package/dist/array-types.d.ts
CHANGED
|
@@ -11,4 +11,52 @@ export type NumericArray = TypedArray | number[];
|
|
|
11
11
|
* TypeScript type covering all typed arrays and classic arrays consisting of numbers
|
|
12
12
|
* @note alias for NumericArray
|
|
13
13
|
*/
|
|
14
|
-
export type NumberArray =
|
|
14
|
+
export type NumberArray = TypedArray | 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
|
@@ -26,11 +26,11 @@ module.exports = __toCommonJS(dist_exports);
|
|
|
26
26
|
|
|
27
27
|
// dist/is-array.js
|
|
28
28
|
function isTypedArray(value) {
|
|
29
|
-
return ArrayBuffer.isView(value) && !(value instanceof DataView)
|
|
29
|
+
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
30
30
|
}
|
|
31
31
|
function isNumericArray(value) {
|
|
32
32
|
if (Array.isArray(value)) {
|
|
33
|
-
return value.length === 0 || typeof value[0] === "number"
|
|
33
|
+
return value.length === 0 || typeof value[0] === "number";
|
|
34
34
|
}
|
|
35
35
|
return isTypedArray(value);
|
|
36
36
|
}
|
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, 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;",
|
|
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";
|
|
1
|
+
export type { TypedArray, TypedArrayConstructor, NumericArray, NumberArray, NumberArray1, NumberArray2, NumberArray3, NumberArray4, NumberArray6, NumberArray8, NumberArray9, NumberArray12, NumberArray16 } from "./array-types.js";
|
|
2
2
|
export { isTypedArray, 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
|
@@ -4,10 +4,10 @@ import { TypedArray, NumericArray } from "./array-types.js";
|
|
|
4
4
|
* @param value value to be tested
|
|
5
5
|
* @returns input as TypedArray, or null
|
|
6
6
|
*/
|
|
7
|
-
export declare function isTypedArray(value: unknown):
|
|
7
|
+
export declare function isTypedArray(value: unknown): value is TypedArray;
|
|
8
8
|
/**
|
|
9
9
|
* Check is an array is a numeric array (typed array or array of numbers)
|
|
10
10
|
* @param value value to be tested
|
|
11
11
|
* @returns input as NumericArray, or null
|
|
12
12
|
*/
|
|
13
|
-
export declare function isNumericArray(value: unknown):
|
|
13
|
+
export declare function isNumericArray(value: unknown): value is NumericArray;
|
package/dist/is-array.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
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
7
|
* @returns input as 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
13
|
* Check is an array is a numeric array (typed array or array of numbers)
|
|
@@ -13,7 +16,7 @@ export function isTypedArray(value) {
|
|
|
13
16
|
*/
|
|
14
17
|
export function isNumericArray(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
21
|
return isTypedArray(value);
|
|
19
22
|
}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
|
-
"version": "4.0.1",
|
|
9
|
+
"version": "4.1.0-alpha.1",
|
|
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": "1a4dbbc6ab46271459d610411a7c644e45135c2c"
|
|
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
|
*/
|
|
@@ -36,4 +40,61 @@ export type NumericArray = TypedArray | number[];
|
|
|
36
40
|
* TypeScript type covering all typed arrays and classic arrays consisting of numbers
|
|
37
41
|
* @note alias for NumericArray
|
|
38
42
|
*/
|
|
39
|
-
export type NumberArray =
|
|
43
|
+
export type NumberArray = TypedArray | 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,22 @@
|
|
|
1
|
-
|
|
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';
|
|
2
20
|
export {isTypedArray, isNumericArray} from './is-array';
|
|
21
|
+
|
|
22
|
+
export type {Bounds, Bounds2D, Bounds3D} from './bounds-types';
|
package/src/is-array.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
// math.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
1
5
|
import {TypedArray, NumericArray} from './array-types';
|
|
2
6
|
|
|
3
7
|
/**
|
|
@@ -5,8 +9,8 @@ import {TypedArray, NumericArray} from './array-types';
|
|
|
5
9
|
* @param value value to be tested
|
|
6
10
|
* @returns input as 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
|
/**
|
|
@@ -14,9 +18,9 @@ export function isTypedArray(value: unknown): TypedArray | null {
|
|
|
14
18
|
* @param value value to be tested
|
|
15
19
|
* @returns input as NumericArray, or null
|
|
16
20
|
*/
|
|
17
|
-
export function isNumericArray(value: unknown):
|
|
21
|
+
export function isNumericArray(value: unknown): value is NumericArray {
|
|
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
25
|
return isTypedArray(value);
|
|
22
26
|
}
|