dabbjs
Version:
general javascript library
92 lines (91 loc) • 2.59 kB
TypeScript
import { IPoint } from "./interfaces";
import { Point } from "./point";
import { Vector2D } from "./vec2d";
export declare const range: (s: number, e: number) => number[];
/**
* loops through an object properties and returns it in a function
* @param obj an object
* @param fn a function as (value: any, key: string, ndx: number) => void
*/
export declare const each: <T>(obj: {
[id: string]: any;
}, fn: (value: T, key: string, ndx: number) => void) => void;
/**
* returns an array of all object properties mapped
* @param obj an object
* @param fn a function as (value: any, key: string, ndx: number) => any
*/
export declare const map: <T>(obj: {
[id: string]: any;
}, fn: (value: T, key: string, ndx: number) => T) => T[];
/**
* filters an object properties by a function
* @param obj an object
* @param fn a function as (value: any, key: string, ndx: number) => any
*/
export declare const filter: <T>(obj: {
[id: string]: any;
}, fn: (value: T, key: string, ndx: number) => T) => {
[id: string]: any;
};
/**
*
* @param obj an object to filter
* @param fn if it returns true array[]= value (key is lost), if object array[] = object, otherwise discarded
*/
export declare const filterArray: <T>(obj: {
[id: string]: any;
}, fn: (value: T, key: string, ndx: number) => T) => T[];
/**
* get/set object property
* @param o object
* @param path path to property "a.b.c"
* @param value undefined to get value, otherwise
*/
export declare const prop: (o: {
[id: string]: any;
}, path: string, value?: any) => any;
/**
* copy all properties in src to obj, and returns obj
* @param obj dest object
* @param src source object
*/
export declare const extend: (obj: {
[id: string]: any;
}, src: {
[id: string]: any;
}) => {
[id: string]: any;
};
/**
* copy properties in src that exists only in obj, and returns obj
* @param obj dest and template object
* @param src source object
*/
export declare const copy: (obj: {
[id: string]: any;
}, src: {
[id: string]: any;
}) => {
[id: string]: any;
};
/**
* creates a NxN matrix
* @param rows amount of rows
* @param cols amount of columns
* @param filler cell filler
*/
export declare const matrix: <T>(rows: number, cols: number, filler: T) => T[][];
/**
* returns the points of an arrow and vector
* @param a first point
* @param b second point
* @param head arrow head length
* @param swipe swipe angle of head line
*/
export declare const arrow: (a: IPoint, b: IPoint, head: number, swipe: number) => {
ang: number;
v: Vector2D;
a: Point;
b: Point;
};