ts-browser-helpers
Version: 
A collection of utility classes, functions and decorators for javascript/typescript projects, for use in the browser.
38 lines • 1.25 kB
TypeScript
import { AnyFunction } from './types';
/**
 * Returns true if the array includes all the elements of the sub array
 * @param arr
 * @param subArr
 */
export declare function includesAll(arr: any[], subArr: IterableIterator<any>): boolean;
/**
 * like Array.prototype.findIndex but from the end
 * @param arr
 * @param predicate
 */
export declare function findLastIndex<T>(arr: T[], predicate: (v: T) => boolean): number;
/**
 * Call f1 before calling f2
 * Sample usage
 * ```
 * const logRender = ()=>console.log('render')
 * obj.render = wrapThisFunction(logRender, obj.beforeRender)
 * // now calling obj.beforeRender(), will log 'render' and then call obj.beforeRender()
 * ```
 * @param f1
 * @param f2
 */
export declare function wrapThisFunction<T extends AnyFunction, T2>(f1: () => void, f2?: T): T;
/**
 * Call f1 with the same params as f2 before calling f2
 * Sample usage
 * ```
 * const logRender = ()=>console.log('render')
 * obj.render = wrapThisFunction(logRender, obj.beforeRender)
 * // now calling obj.beforeRender(), will log 'render' and then call obj.beforeRender()
 * ```
 * @param f1
 * @param f2
 */
export declare function wrapThisFunction2<T extends AnyFunction, T2>(f1: T, f2?: T): T;
//# sourceMappingURL=misc.d.ts.map