@genart-api/core
Version:
Platform-independent extensible API for browser-based generative art
65 lines (64 loc) • 2.61 kB
TypeScript
import type { TypedArray } from "./api/utils";
export declare const ensure: <T>(x: T, msg: string) => NonNullable<T>;
export declare const isBigInt: (x: any) => x is bigint;
export declare const isNumber: (x: any) => x is number;
export declare const isString: (x: any) => x is string;
export declare const isPrim: (x: any) => x is bigint | boolean | number | string | symbol;
export declare const isFunction: <T extends Function>(x: any) => x is T;
export declare const isNumericArray: (x: any) => x is number[];
export declare const isStringArray: (x: any) => x is string[];
export declare const isTypedArray: (x: any) => x is TypedArray;
export declare const isInRange: (x: number, min: number, max: number) => boolean;
export declare const u8: (x: number) => string;
export declare const u16: (x: number) => string;
export declare const u24: (x: number) => string;
export declare const u32: (x: number) => string;
export declare const stringifyBigInt: (x: bigint, radix?: number) => string;
export declare const parseBigInt: (x: string) => bigint;
export declare const parseBigInt128: (x: bigint) => Uint32Array<ArrayBuffer>;
export declare const stringifyJSON: (value: any) => string;
export declare const valuePrec: (step: number) => number;
export declare const formatValuePrec: (step: number) => (x: number) => string;
/**
* @remarks
* Implementation based on [thi.ng/equiv](https://thi.ng/equiv).
*
* @param a
* @param b
*/
export declare const equiv: (a: any, b: any) => boolean;
/**
* @remarks
* Implementation based on [thi.ng/equiv](https://thi.ng/equiv).
*
* @param a
* @param b
*/
export declare const equivObject: (a: Record<any, any>, b: Record<any, any>) => boolean;
/**
* @remarks
* Implementation based on [thi.ng/equiv](https://thi.ng/equiv).
*
* @param a
* @param b
*/
export declare const equivArrayLike: (a: ArrayLike<any>, b: ArrayLike<any>) => boolean;
export declare const parseUUID: (uuid: string) => Uint32Array<ArrayBuffer>;
/**
* MurmurHash3 128bit.
*
* @remarks
* Based on this implementation:
* https://github.com/bryc/code/blob/master/jshash/hashes/murmurhash3_128.js
*
* Following modifications:
* - Added various helper fns and use u32 arrays instead of sets of individual
* state vars
* - Refactored & deduplicate internal state to be more compact
* - Replaced large switch statement for processing remaining bytes
*
* @param buf
* @param seed
*/
export declare const hashBytes: (buf: Uint8Array, seed?: number) => Uint32Array<ArrayBufferLike>;
export declare const hashString: (x: string, seed?: number) => Uint32Array<ArrayBufferLike>;