UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

18 lines 486 B
/** * @public * Like _Array.map but where the callback returns null it will be omitted from the result. * * @remarks * See {@link arrayCompactMap}. */ export function arrayCompactMap(items, map) { const mapped = []; for (let i = 0, iEnd = items.length; i < iEnd; ++i) { const transformed = map(items[i], i); if (transformed !== null) { mapped.push(transformed); } } return mapped; } //# sourceMappingURL=array-compact-map.js.map