node-darts
Version:
Node.js Native Addon for Darts (Double-ARray Trie System)
80 lines (79 loc) • 2.7 kB
TypeScript
/**
* node-darts: Node.js Native Addon for Darts (Double-ARray Trie System)
* ESM wrapper for the native module
*
* @packageDocumentation
*/
import { DartsNative, TraverseCallback } from './core/types';
/**
* Wrapper class for native module in ESM context
* Adds error handling and provides a TypeScript-friendly interface
*/
export declare class DartsNativeWrapper implements DartsNative {
/**
* Creates a dictionary object
* @returns dictionary handle
*/
createDictionary(): number;
/**
* Destroys a dictionary object
* @param handle dictionary handle
*/
destroyDictionary(handle: number): void;
/**
* Loads a dictionary file
* @param handle dictionary handle
* @param filePath path to the dictionary file
* @returns true if successful, false otherwise
*/
loadDictionary(handle: number, filePath: string): boolean;
/**
* Saves a dictionary file
* @param handle dictionary handle
* @param filePath destination file path
* @returns true if successful, false otherwise
*/
saveDictionary(handle: number, filePath: string): boolean;
/**
* Performs an exact match search
* @param handle dictionary handle
* @param key search key
* @returns the corresponding value if found, -1 otherwise
*/
exactMatchSearch(handle: number, key: string): number;
/**
* Performs a common prefix search
* @param handle dictionary handle
* @param key search key
* @returns array of found values
*/
commonPrefixSearch(handle: number, key: string): number[];
/**
* Traverses the trie
* @param handle dictionary handle
* @param key search key
* @param callback callback function
*/
traverse(handle: number, key: string, callback: TraverseCallback): void;
/**
* Builds a Double-Array
* @param keys array of keys
* @param values array of values (indices are used if omitted)
* @returns dictionary handle
*/
build(keys: string[], values?: number[]): number;
/**
* Gets the size of the dictionary
* @param handle dictionary handle
* @returns size of the dictionary
*/
size(handle: number): number;
}
export declare const dartsNative: DartsNativeWrapper;
export { default as Dictionary } from './core/dictionary';
export { default as Builder } from './core/builder';
export { default as TextDarts } from './text-darts';
export * from './core/types';
export * from './core/errors';
export * from './core/utils';
export { createDictionary, createBuilder, loadDictionary, buildDictionary, buildAndSaveDictionary, buildAndSaveDictionarySync, } from './index';