UNPKG

functionalscript

Version:

FunctionalScript is a purely functional subset of JavaScript

22 lines (21 loc) 1.05 kB
import type { Leaf1, Leaf2, Branch3, Branch5, TNode } from '../types/module.f.ts'; import type { List } from '../../list/module.f.ts'; import { type Compare } from '../../function/compare/module.f.ts'; import type { Index3, Index5 } from "../../array/module.f.ts"; type FirstLeaf1<T> = readonly [Index3, Leaf1<T>]; type FirstBranch3<T> = readonly [1, Branch3<T>]; type FirstLeaf2<T> = readonly [Index5, Leaf2<T>]; type FirstBranch5<T> = readonly [1 | 3, Branch5<T>]; type First<T> = FirstLeaf1<T> | FirstBranch3<T> | FirstLeaf2<T> | FirstBranch5<T>; type PathItem3<T> = readonly [0 | 2, Branch3<T>]; type PathItem5<T> = readonly [0 | 2 | 4, Branch5<T>]; export type PathItem<T> = PathItem3<T> | PathItem5<T>; export type Path<T> = List<PathItem<T>>; export type Result<T> = { readonly first: First<T>; readonly tail: Path<T>; }; export declare const find: <T>(c: Compare<T>) => (node: TNode<T>) => Result<T>; export declare const isFound: <T>([i]: First<T>) => boolean; export declare const value: <T>([i, r]: First<T>) => T | null; export {};