Function mapNotNullish
- map
Not <T, O>(array, transformer): NonNullable<O>[]Nullish Type Parameters
Parameters
Returns NonNullable<O>[]
A new array with all elements transformed by the given transformer, except the ones that were transformed to
nullorundefined.Example: Basic usage
import { mapNotNullish } from "@std/collections/map-not-nullish";
import { assertEquals } from "@std/assert";
const people = [
{ middleName: null },
{ middleName: "William" },
{ middleName: undefined },
{ middleName: "Martha" },
];
const foundMiddleNames = mapNotNullish(people, (people) => people.middleName);
assertEquals(foundMiddleNames, ["William", "Martha"]);
Returns a new array, containing all elements in the given array transformed using the given transformer, except the ones that were transformed to
nullorundefined.