// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
/**
 * Returns a new array, containing all elements in the given array transformed using the given transformer, except the ones
 * that were transformed to `null` or `undefined`
 *
 * Example:
 *
 * ```ts
 * import { mapNotNullish } from "https://deno.land/std@$STD_VERSION/collections/map_not_nullish.ts";
 * import { assertEquals } from "https://deno.land/std@$STD_VERSION/testing/asserts.ts";
 *
 * const people = [
 *     { middleName: null },
 *     { middleName: 'William' },
 *     { middleName: undefined },
 *     { middleName: 'Martha' },
 * ]
 * const foundMiddleNames = mapNotNullish(people, it => it.middleName)
 *
 * assertEquals(foundMiddleNames, [ 'William', 'Martha' ])
 * ```
 */ export function mapNotNullish(array, transformer) {
    const ret = [];
    for (const element of array){
        const transformedElement = transformer(element);
        if (transformedElement !== undefined && transformedElement !== null) {
            ret.push(transformedElement);
        }
    }
    return ret;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImh0dHBzOi8vZGVuby5sYW5kL3N0ZEAwLjE2Ni4wL2NvbGxlY3Rpb25zL21hcF9ub3RfbnVsbGlzaC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvLyBDb3B5cmlnaHQgMjAxOC0yMDIyIHRoZSBEZW5vIGF1dGhvcnMuIEFsbCByaWdodHMgcmVzZXJ2ZWQuIE1JVCBsaWNlbnNlLlxuLy8gVGhpcyBtb2R1bGUgaXMgYnJvd3NlciBjb21wYXRpYmxlLlxuXG4vKipcbiAqIFJldHVybnMgYSBuZXcgYXJyYXksIGNvbnRhaW5pbmcgYWxsIGVsZW1lbnRzIGluIHRoZSBnaXZlbiBhcnJheSB0cmFuc2Zvcm1lZCB1c2luZyB0aGUgZ2l2ZW4gdHJhbnNmb3JtZXIsIGV4Y2VwdCB0aGUgb25lc1xuICogdGhhdCB3ZXJlIHRyYW5zZm9ybWVkIHRvIGBudWxsYCBvciBgdW5kZWZpbmVkYFxuICpcbiAqIEV4YW1wbGU6XG4gKlxu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