/** * @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: ArrayLike, map: (item: TItem, index: number) => TTransformed | null ) : TTransformed[] { const mapped: TTransformed[] = []; for (let i = 0, iEnd = items.length; i < iEnd; ++i) { const transformed = map(items[i], i); if (transformed !== null) { mapped.push(transformed); } } return mapped; }