@math.gl/types
Advanced tools
Comparing version 4.0.0 to 4.0.1
/** | ||
* TypeScript type covering all typed arrays | ||
*/ | ||
export declare type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array; | ||
export declare type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor; | ||
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array; | ||
export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor; | ||
/** | ||
* TypeScript type covering all typed arrays and classic arrays consisting of numbers | ||
*/ | ||
export declare type NumericArray = TypedArray | number[]; | ||
export type NumericArray = TypedArray | number[]; | ||
/** | ||
@@ -14,3 +14,2 @@ * TypeScript type covering all typed arrays and classic arrays consisting of numbers | ||
*/ | ||
export declare type NumberArray = NumericArray; | ||
//# sourceMappingURL=array-types.d.ts.map | ||
export type NumberArray = NumericArray; |
export {}; | ||
//# sourceMappingURL=array-types.js.map |
@@ -21,2 +21,1 @@ declare function BigIntUnavailable(): void; | ||
export { BigUint64ArrayCtor as BigUint64Array }; | ||
//# sourceMappingURL=bigint.d.ts.map |
@@ -0,53 +1,44 @@ | ||
// BigInt compatibility layer | ||
// Inspired by ArrowJS (under Apache2 license) | ||
// https://github.com/apache/arrow/blob/master/js/src/util/compat.ts | ||
// Requires tsconfig.json: target=esnext or (lib: esnext.bigint) | ||
// Requires eslint: env: {es2020: true} | ||
const ERR_BIGINT_UNAVAILABLE = 'BigInt is not available in this environment'; | ||
function BigIntUnavailable() { | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
} | ||
BigIntUnavailable.asIntN = () => { | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
}; | ||
BigIntUnavailable.asUintN = () => { | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
}; | ||
class BigInt64ArrayUnavailable { | ||
static get BYTES_PER_ELEMENT() { | ||
return 8; | ||
} | ||
static of() { | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
} | ||
static from() { | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
} | ||
constructor() { | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
} | ||
static get BYTES_PER_ELEMENT() { | ||
return 8; | ||
} | ||
static of() { | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
} | ||
static from() { | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
} | ||
constructor() { | ||
throw new Error(ERR_BIGINT_UNAVAILABLE); | ||
} | ||
} | ||
export const BigIntAvailable = typeof BigInt !== 'undefined'; | ||
export const BigInt64ArrayAvailable = typeof BigInt64Array !== 'undefined'; | ||
export const BigUint64ArrayAvailable = typeof BigUint64Array !== 'undefined'; | ||
const BigIntCtor = (() => { | ||
return BigIntAvailable ? BigInt : BigIntUnavailable; | ||
return BigIntAvailable ? BigInt : BigIntUnavailable; | ||
})(); | ||
const BigInt64ArrayCtor = (() => { | ||
return BigInt64ArrayAvailable ? BigInt64Array : BigInt64ArrayUnavailable; | ||
return BigInt64ArrayAvailable ? BigInt64Array : BigInt64ArrayUnavailable; | ||
})(); | ||
const BigUint64ArrayCtor = (() => { | ||
return BigUint64ArrayAvailable ? [BigUint64Array] : [BigInt64ArrayUnavailable]; | ||
return BigUint64ArrayAvailable ? [BigUint64Array] : [BigInt64ArrayUnavailable]; | ||
})(); | ||
export { BigIntCtor as BigInt }; | ||
export { BigInt64ArrayCtor as BigInt64Array }; | ||
export { BigUint64ArrayCtor as BigUint64Array }; | ||
//# sourceMappingURL=bigint.js.map |
@@ -1,3 +0,2 @@ | ||
export type { TypedArray, TypedArrayConstructor, NumericArray, NumberArray } from './array-types'; | ||
export { isTypedArray, isNumericArray } from './is-array'; | ||
//# sourceMappingURL=index.d.ts.map | ||
export type { TypedArray, TypedArrayConstructor, NumericArray, NumberArray } from "./array-types.js"; | ||
export { isTypedArray, isNumericArray } from "./is-array.js"; |
export { isTypedArray, isNumericArray } from "./is-array.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { TypedArray, NumericArray } from './array-types'; | ||
import { TypedArray, NumericArray } from "./array-types.js"; | ||
/** | ||
@@ -14,2 +14,1 @@ * Check is an array is a typed array | ||
export declare function isNumericArray(value: unknown): NumericArray | null; | ||
//# sourceMappingURL=is-array.d.ts.map |
@@ -0,11 +1,19 @@ | ||
/** | ||
* Check is an array is a typed array | ||
* @param value value to be tested | ||
* @returns input as TypedArray, or null | ||
*/ | ||
export function isTypedArray(value) { | ||
return ArrayBuffer.isView(value) && !(value instanceof DataView) ? value : null; | ||
return ArrayBuffer.isView(value) && !(value instanceof DataView) ? value : null; | ||
} | ||
/** | ||
* Check is an array is a numeric array (typed array or array of numbers) | ||
* @param value value to be tested | ||
* @returns input as NumericArray, or null | ||
*/ | ||
export function isNumericArray(value) { | ||
if (Array.isArray(value)) { | ||
return value.length === 0 || typeof value[0] === 'number' ? value : null; | ||
} | ||
return isTypedArray(value); | ||
if (Array.isArray(value)) { | ||
return value.length === 0 || typeof value[0] === 'number' ? value : null; | ||
} | ||
return isTypedArray(value); | ||
} | ||
//# sourceMappingURL=is-array.js.map |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"keywords": [ | ||
@@ -27,5 +27,5 @@ "typescript", | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.js", | ||
"require": "./dist/index.cjs", | ||
"types": "./dist/index.d.ts" | ||
"require": "./dist/index.cjs" | ||
} | ||
@@ -40,3 +40,3 @@ }, | ||
], | ||
"gitHead": "b7af99a25965af5112307552084fbaf5d4d53b7d" | ||
"gitHead": "33f369ba3a259f79acc3fa8181190c9da8841648" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
250
15375
211223
17