@thi.ng/api
Advanced tools
Comparing version 8.3.9 to 8.4.0
# Change Log | ||
- **Last updated**: 2022-08-01T14:53:59Z | ||
- **Last updated**: 2022-08-15T15:40:55Z | ||
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub) | ||
@@ -12,2 +12,12 @@ | ||
## [8.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/api@8.4.0) (2022-08-15) | ||
#### 🚀 Features | ||
- add i64/u64 support for typed arrays ([0bb5277](https://github.com/thi-ng/umbrella/commit/0bb5277)) | ||
- add various 64bit bigint related types & lookups | ||
- add BIT_SHIFTS LUT | ||
- update sizeOf() | ||
- update typedArray() | ||
## [8.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/api@8.3.0) (2021-11-17) | ||
@@ -14,0 +24,0 @@ |
{ | ||
"name": "@thi.ng/api", | ||
"version": "8.3.9", | ||
"version": "8.4.0", | ||
"description": "Common, generic types, interfaces & mixins", | ||
@@ -38,3 +38,3 @@ "type": "module", | ||
"@microsoft/api-extractor": "^7.25.0", | ||
"@thi.ng/testament": "^0.2.10", | ||
"@thi.ng/testament": "^0.2.11", | ||
"rimraf": "^3.0.2", | ||
@@ -226,3 +226,3 @@ "tools": "^0.0.1", | ||
}, | ||
"gitHead": "976ccd698cedaa60dcef2e69030a5eb98898cc4a\n" | ||
"gitHead": "295e76c6f68ef34ba2117ff77612848e09f5c587\n" | ||
} |
export declare type ArrayLikeIterable<T> = ArrayLike<T> & Iterable<T>; | ||
export declare type NumericArray = number[] | TypedArray; | ||
export declare type TypedArray = Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array; | ||
export declare type BigTypedArray = BigInt64Array | BigUint64Array; | ||
export declare type FloatArray = Float32Array | Float64Array; | ||
@@ -10,2 +11,3 @@ export declare type IntArray = Int8Array | Int16Array | Int32Array; | ||
export declare type UIntArrayConstructor = Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Uint16ArrayConstructor | Uint32ArrayConstructor; | ||
export declare type BigIntArrayConstructor = BigInt64ArrayConstructor | BigUint64ArrayConstructor; | ||
export declare type TypedArrayConstructor = FloatArrayConstructor | IntArrayConstructor | UIntArrayConstructor; | ||
@@ -19,2 +21,3 @@ /** | ||
export declare type Type = "u8" | "u8c" | "i8" | "u16" | "i16" | "u32" | "i32" | "f32" | "f64"; | ||
export declare type BigType = "i64" | "u64"; | ||
export declare type UintType = "u8" | "u8c" | "u16" | "u32"; | ||
@@ -53,3 +56,4 @@ export declare type IntType = "i8" | "i16" | "i32"; | ||
/** | ||
* Size information (in bytes) for {@link Type}. Also see {@link sizeOf}. | ||
* Size information (in bytes) for {@link Type} and {@link BigType}. Also see | ||
* {@link sizeOf}. | ||
*/ | ||
@@ -64,8 +68,28 @@ export declare const SIZEOF: { | ||
i32: number; | ||
i64: number; | ||
u64: number; | ||
f32: number; | ||
f64: number; | ||
}; | ||
/** | ||
* Bit shift values to convert byte addresses into array indices for all | ||
* {@link Type}s and {@link BigType}s. | ||
*/ | ||
export declare const BIT_SHIFTS: { | ||
i8: number; | ||
u8: number; | ||
u8c: number; | ||
i16: number; | ||
u16: number; | ||
i32: number; | ||
u32: number; | ||
i64: number; | ||
u64: number; | ||
f32: number; | ||
f64: number; | ||
}; | ||
export declare const FLOAT_ARRAY_CTORS: Record<FloatType, FloatArrayConstructor>; | ||
export declare const INT_ARRAY_CTORS: Record<IntType, IntArrayConstructor>; | ||
export declare const UINT_ARRAY_CTORS: Record<UintType, UIntArrayConstructor>; | ||
export declare const BIGINT_ARRAY_CTORS: Record<BigType, BigIntArrayConstructor>; | ||
export declare const TYPEDARRAY_CTORS: Record<Type, TypedArrayConstructor>; | ||
@@ -90,2 +114,6 @@ export interface TypedArrayTypeMap extends Record<Type | GLType, TypedArray> { | ||
} | ||
export interface BigTypedArrayTypeMap extends Record<BigType, BigTypedArray> { | ||
i64: BigInt64Array; | ||
u64: BigUint64Array; | ||
} | ||
/** | ||
@@ -125,6 +153,6 @@ * Returns canonical {@link Type} value of `type` by first | ||
*/ | ||
export declare const sizeOf: (type: GLType | Type) => number; | ||
export declare const sizeOf: (type: Type | BigType | GLType) => number; | ||
/** | ||
* Constructs new typed array of given {@link Type}/{@link GLType}. Supports all | ||
* arities of standard typed array ctors. | ||
* Constructs new typed array of given {@link Type}, {@link GLType} or | ||
* {@link BigType}. Supports all arities of standard typed array ctors. | ||
* | ||
@@ -136,2 +164,5 @@ * @param type - array type enum | ||
export declare function typedArray<T extends Type | GLType>(type: T, buf: ArrayBufferLike, byteOffset: number, length?: number): TypedArrayTypeMap[T]; | ||
export declare function typedArray<T extends BigType>(type: T, length: number): BigTypedArrayTypeMap[T]; | ||
export declare function typedArray<T extends BigType>(type: T, src: ArrayLike<bigint> | ArrayBufferLike): BigTypedArrayTypeMap[T]; | ||
export declare function typedArray<T extends BigType>(type: T, buf: ArrayBufferLike, byteOffset: number, length?: number): BigTypedArrayTypeMap[T]; | ||
/** | ||
@@ -138,0 +169,0 @@ * Takes an {@link NumericArray} and returns its corresponding {@link Type} ID. |
@@ -50,3 +50,4 @@ /** | ||
/** | ||
* Size information (in bytes) for {@link Type}. Also see {@link sizeOf}. | ||
* Size information (in bytes) for {@link Type} and {@link BigType}. Also see | ||
* {@link sizeOf}. | ||
*/ | ||
@@ -61,5 +62,24 @@ export const SIZEOF = { | ||
i32: 4, | ||
i64: 8, | ||
u64: 8, | ||
f32: 4, | ||
f64: 8, | ||
}; | ||
/** | ||
* Bit shift values to convert byte addresses into array indices for all | ||
* {@link Type}s and {@link BigType}s. | ||
*/ | ||
export const BIT_SHIFTS = { | ||
i8: 0, | ||
u8: 0, | ||
u8c: 0, | ||
i16: 1, | ||
u16: 1, | ||
i32: 2, | ||
u32: 2, | ||
i64: 3, | ||
u64: 3, | ||
f32: 2, | ||
f64: 2, | ||
}; | ||
export const FLOAT_ARRAY_CTORS = { | ||
@@ -80,2 +100,6 @@ f32: Float32Array, | ||
}; | ||
export const BIGINT_ARRAY_CTORS = { | ||
i64: BigInt64Array, | ||
u64: BigUint64Array, | ||
}; | ||
export const TYPEDARRAY_CTORS = { | ||
@@ -126,5 +150,6 @@ ...FLOAT_ARRAY_CTORS, | ||
*/ | ||
export const sizeOf = (type) => SIZEOF[asNativeType(type)]; | ||
export const sizeOf = (type) => SIZEOF[type] || SIZEOF[asNativeType(type)]; | ||
export function typedArray(type, ...xs) { | ||
return new TYPEDARRAY_CTORS[asNativeType(type)](...xs); | ||
const ctor = BIGINT_ARRAY_CTORS[type]; | ||
return new (ctor || TYPEDARRAY_CTORS[asNativeType(type)])(...xs); | ||
} | ||
@@ -131,0 +156,0 @@ /** |
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
120048
2380