1.0.8 • Published 5 years ago

@topl/tack v1.0.8

Weekly downloads
122
License
MIT
Repository
-
Last release
5 years ago

📌 tack

tack is just a place to stick things that are needed cross-project. It is not meant to be a big/professional library like lodash. Instead, it contains useful utilities and algorithms we commonly need with boilerplate so we don't need to waste a bunch of time configuring rollup for each little module. Instead, the modules all house together in this package, and thanks to treeshaking, we can still load only what we need.

api

assert

declare function assert(condition: any, message?: string): void;

Throw an assertion error with the given message if the condition is not true.

findLast

declare function findLast<T>(predicate: (it: T, index: number) => boolean, array: any[]): T;

Find the last item of an array that matches the predicate.

head

declare function head<T>(it: Iterable<T>): T;

Return the first item of an iterable.

partition

declare function partition<T>(predicate: (item: T, index: number) => boolean, array: T[]): [T[], T[]];

Split an array into two arrays, ones that respectively contain all the items matching and not matching the predicate.

TopologicalSort

declare class TopologicalSort<T> {
    nodes: Set<T>;
    private edges;
    addEdge(source: T, target: T): void;
    sort(): T[];
    visit(node: T, list: T[], permanent: Set<T>, temporary: Set<T>): void;
}

getAt

Get the object at the path

export declare function getAt<T, F = T>(path: string[], target: T): F;

license

See LICENSE

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago