@types/static-kdtree
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Installation

npm install --save @types/static-kdtree

Summary

This package contains type definitions for static-kdtree (https://github.com/mikolalysenko/static-kdtree).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/static-kdtree.

index.d.ts

import ndarray = require("ndarray");

// ref: https://github.com/microsoft/TypeScript/pull/40002
type TupleOf<T, N extends number> = N extends N ? number extends N ? T[] : _TupleOf<T, N, []> : never;
type _TupleOf<T, N extends number, R extends unknown[]> = R["length"] extends N ? R : _TupleOf<T, N, [T, ...R]>;

type ISerialized<D extends number = number> = {
    p: Array<TupleOf<number, D>>;
    i: number[];
} | {
    d: number;
};

type TVisitor = (id: number) => any;

type TNdarray = ReturnType<typeof ndarray>;

declare class KDTree<D extends number = number> {
    readonly dimension: number;
    readonly length: number;

    constructor(points: ReturnType<typeof ndarray>, ids: number[], n: number, d: D);

    range(lo: number[], hi: number[], visit: TVisitor): number;
    rnn(point: TupleOf<number, D>, radius: number, visit: TVisitor): void;
    nn(point: TupleOf<number, D>, maxDistance?: number): number;
    knn(point: TupleOf<number, D>, maxPoints?: number, maxDistance?: number): number[];
    serialize(): ISerialized<D>;
    dispose(): void;
}

declare function createKDTree<D extends number = number>(
    points: ReadonlyArray<TupleOf<number, D>> | TNdarray,
): KDTree<D>;
declare namespace createKDTree {
    function deserialize<D extends number>(data: ISerialized<D>): KDTree<D>;
}

export = createKDTree;

Additional Details

  • Last updated: Tue, 07 Nov 2023 15:11:36 GMT
  • Dependencies: @types/ndarray

Credits

These definitions were written by Zheyang Song.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/static-kdtree

Weekly Downloads

92

Version

1.0.3

License

MIT

Unpacked Size

5.34 kB

Total Files

5

Last publish

Collaborators

  • types