valdo-js
Version:
JavaScript/WASM bindings for Valdo time series anomaly detection library
84 lines (79 loc) • 3.08 kB
TypeScript
/* tslint:disable */
/* eslint-disable */
/**
* Initialize the WASM module
*/
export function main(): void;
export enum AnomalyStatus {
Normal = 0,
Anomaly = 1,
}
export class Detector {
free(): void;
/**
* Create a detector with default parameters for quick setup
*/
static createDefault(window_size: bigint): Detector;
/**
* Create a new Detector with specified window size and optional parameters
*
* # Arguments
* * `window_size` - Size of the sliding window for processing
* * `quantile` - Optional quantile parameter for SPOT detector (default: 0.0001)
* * `level` - Optional level parameter for SPOT detector (default: 0.998)
* * `max_excess` - Optional maximum excess for SPOT detector (default: 200)
*/
constructor(window_size: bigint, quantile?: number | null, level?: number | null, max_excess?: number | null);
/**
* Train the detector on historical data
*
* # Arguments
* * `timestamps` - Array of timestamps
* * `values` - Array of values
*/
train(timestamps: Float64Array, values: Float64Array): void;
/**
* Detect anomalies in a new data point
*
* # Arguments
* * `timestamp` - Timestamp of the data point
* * `value` - Value of the data point
*
* # Returns
* AnomalyStatus: Normal or Anomaly
*/
detect(timestamp: number, value: number): AnomalyStatus;
}
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
export interface InitOutput {
readonly memory: WebAssembly.Memory;
readonly main: () => void;
readonly detector_createDefault: (a: bigint) => [number, number, number];
readonly __wbg_detector_free: (a: number, b: number) => void;
readonly detector_new: (a: bigint, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
readonly detector_detect: (a: number, b: number, c: number) => [number, number, number];
readonly detector_train: (a: number, b: number, c: number, d: number, e: number) => [number, number];
readonly __wbindgen_export_0: WebAssembly.Table;
readonly __externref_table_dealloc: (a: number) => void;
readonly __wbindgen_malloc: (a: number, b: number) => number;
readonly __wbindgen_start: () => void;
}
export type SyncInitInput = BufferSource | WebAssembly.Module;
/**
* Instantiates the given `module`, which can either be bytes or
* a precompiled `WebAssembly.Module`.
*
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
*
* @returns {InitOutput}
*/
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
/**
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
* for everything else, calls `WebAssembly.instantiate` directly.
*
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
*
* @returns {Promise<InitOutput>}
*/
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;