UNPKG

637 BTypeScriptView Raw
1/**
2 * @name arrayFilter
3 * @summary Filters undefined and (optionally) null values from an array
4 * @description
5 * Returns a new array with all `undefined` values removed. Optionally, when `allowNulls = false`, it removes the `null` values as well
6 * @example
7 * <BR>
8 *
9 * ```javascript
10 * import { arrayFilter } from '@polkadot/util';
11 *
12 * arrayFilter([0, void 0, true, null, false, '']); // [0, true, null, false, '']
13 * arrayFilter([0, void 0, true, null, false, ''], false); // [0, true, false, '']
14 * ```
15 */
16export declare function arrayFilter<T = unknown>(array: readonly (T | null | undefined)[], allowNulls?: boolean): T[];