UNPKG

2.57 kBTypeScriptView Raw
1/**
2 * Simpler helper method to check for undefined simply for the benefit of
3 * gaining better compression when minified by not needing to have multiple
4 * comparisons to the `undefined` keyword in the codebase.
5 */
6export declare function isUndefined(value: any): value is undefined;
7/**
8 * Simpler helper method to check for a boolean type simply for the benefit of
9 * gaining better compression when minified by not needing to have multiple
10 * `typeof` comparisons in the codebase.
11 */
12export declare function isBoolean(value: any): value is boolean;
13/**
14 * Assigns (shallow copies) the properties of `src` onto `dest`, if the
15 * corresponding property on `dest` === `undefined`.
16 *
17 * @param {Object} dest The destination object.
18 * @param {Object} src The source object.
19 * @return {Object} The destination object (`dest`)
20 */
21export declare function defaults(dest: any, src: any): any;
22/**
23 * Truncates the `str` at `len - ellipsisChars.length`, and adds the `ellipsisChars` to the
24 * end of the string (by default, two periods: '..'). If the `str` length does not exceed
25 * `len`, the string will be returned unchanged.
26 *
27 * @param {String} str The string to truncate and add an ellipsis to.
28 * @param {Number} truncateLen The length to truncate the string at.
29 * @param {String} [ellipsisChars=...] The ellipsis character(s) to add to the end of `str`
30 * when truncated. Defaults to '...'
31 */
32export declare function ellipsis(str: string, truncateLen: number, ellipsisChars?: string): string;
33/**
34 * Removes array elements by value. Mutates the input array.
35 *
36 * Using this instead of the ES5 Array.prototype.filter() function to prevent
37 * creating many new arrays in memory for removing an element.
38 *
39 * @param arr The array to remove elements from. This array is mutated.
40 * @param fn The element to remove.
41 */
42export declare function remove<T>(arr: T[], item: T): void;
43/**
44 * Removes array elements based on a filtering function. Mutates the input
45 * array.
46 *
47 * Using this instead of the ES5 Array.prototype.filter() function to prevent
48 * creating many new arrays in memory for filtering.
49 *
50 * @param arr The array to remove elements from. This array is mutated.
51 * @param fn The predicate function which should return `true` to remove an
52 * element.
53 */
54export declare function removeWithPredicate<T>(arr: T[], fn: (item: T) => boolean): void;
55/**
56 * Function that should never be called but is used to check that every
57 * enum value is handled using TypeScript's 'never' type.
58 */
59export declare function assertNever(theValue: never): void;