node-darts
Version:
Node.js Native Addon for Darts (Double-ARray Trie System)
52 lines (51 loc) • 2.1 kB
TypeScript
import Dictionary from './dictionary';
import { BuildOptions } from './types';
/**
* Darts Dictionary Builder class
* A class for building Double-Array Trie
*/
export default class Builder {
private readonly name;
/**
* Builds a Double-Array from keys and values
* @param keys array of keys (preferably sorted in dictionary order)
* @param values array of values (indices are used if omitted)
* @param options build options
* @returns the constructed Dictionary object
* @throws {BuildError} if the build fails
*/
build(inputKeys: string[], inputValues?: number[], options?: BuildOptions): Dictionary;
/**
* Builds a Double-Array from keys and values, and saves it to a file asynchronously
* @param keys array of keys (preferably sorted in dictionary order)
* @param filePath destination file path
* @param values array of values (indices are used if omitted)
* @param options build options
* @returns true if successful, false otherwise
* @throws {BuildError} if the build fails
*/
buildAndSave(keys: string[], filePath: string, values?: number[], options?: BuildOptions): Promise<boolean>;
/**
* Builds a Double-Array from keys and values, and saves it to a file synchronously
* @param keys array of keys (preferably sorted in dictionary order)
* @param filePath destination file path
* @param values array of values (indices are used if omitted)
* @param options build options
* @returns true if successful, false otherwise
* @throws {BuildError} if the build fails
*/
buildAndSaveSync(keys: string[], filePath: string, values?: number[], options?: BuildOptions): boolean;
/**
* Validates the input values
* @param keys array of keys
* @param values array of values
* @throws {BuildError} if the input values are invalid
*/
private static validateInput;
/**
* Checks if an array is sorted
* @param arr array to check
* @returns true if sorted, false otherwise
*/
private static isSorted;
}