@ainc/utils

Let's do something nice with @ainc/utils!

Usage no npm install needed!

<script type="module">
  import aincUtils from 'https://cdn.skypack.dev/@ainc/utils';
</script>

README

@ainc/utils

Let's do something nice with @ainc/utils!

Install

$ yarn add @ainc/utils

Usage

import * as utils from '@ainc/utils';

API

  • assign<T, P>(target: T, origin: P): Assign<T, P>;
  • base64:
    • atob(str: string): string;
    • btoa(str: string): string;
    • encode(str: string): number[];
    • decode(number[], start?: number, end?: number): string;
  • chain(...args: Function[]): Function;
  • compose(...args: Function[]): Function;
  • debounce<T, P>(handler: (...args: T[]) => P): (...args: T[]) => P | Promise<P>;
  • defer<T>(time: number, callback: () => T): Promise<T>;
  • delay(time: number, callback: () => void): () => void;
  • equal<T, P>(target: T, origin: P): boolean;
  • new EventEmitter():
    • on(type: string, handler: Function): this;
    • once(type: string, handler: Function): this;
    • off(type: string, handler: Function): this;
    • emit(type: string, ...args: unknown[]): this;
  • flow(...args: Function[]): Function;
  • hex:
    • encode(str: string): number[];
    • decode(number[], start?: number, end?: number): string;
  • new Indexed(list?: string[], map?: { [key: string]: number }):
    • add(value: string): void;
    • set(value: string, index: number): void;
    • get(index: number): string;
    • indexOf(value: string): number;
  • interval(time: number, callback: () => void): () => void;
  • memory<T extends Function>(handler: T): T;
  • nextTick<T>(callback?: () => T): Promise<void | T>;
  • noop(): void;
  • observer<T>(): Observer<T>;
  • omit<T, P extends keyof T>(origin: T, keys: P[]): Omit<T, P>;
  • once(target: Target, name: string): Promise<void>;
  • new Onion<T extends State = {}, P = void>:
    • add(handler: (context: T & { next(): void | P }) => void | P): () => void;
    • call(state: T, callback?: (state: T) => void | P): void | P;
  • pick<T, P extends keyof T>(origin: T, keys: P[]): Pick<T, P>;
  • promisify<T>(handler: Function): Promise<T>;
  • proxy<T, P = {}>(target: T, proto?: P): Proxy<T, P>;
  • rAF(callback: () => void): () => void;
  • repeat<T>(count: number, handler: (index: number, total: number) => T): T[];
  • step<T, P>(list: T[], handler: Handler<T, P>): void | P;
  • throttle<T, P>(handler: (...args: T[]) => P): (...args: T[]) => P | Promise<P>;
  • utf8:
    • encode(str: string): number[];
    • decode(number[], start?: number, end?: number): string;