filter-and-map
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

filter-and-map

Installation

npm install filter-and-map

Usage

In your code's entry point (usually index.* or main.*), include the following line:

import 'filter-and-map';

You should now have access to Array.prototype.filterAndMap throughout the entirety of your code.

Array.prototype.filterAndMap

The Array.prototype.filterAndMap method can be used like so:

const example = [
    { id: 1, isValid: true, name: "Bret" },
    { id: 2, isValid: false, name: "Gary" },
    { id: 3, isValid: true, name: "Shafran" }
]

const result = example.filterAndMap((item) => {
    if (item.isValid) return item.name;
});

// or we could write:
const result = example.filterAndMap((item) => item.isValid ? item.name : undefined);

Readme

Keywords

none

Package Sidebar

Install

npm i filter-and-map

Weekly Downloads

37

Version

1.0.7

License

ISC

Unpacked Size

2.98 kB

Total Files

4

Last publish

Collaborators

  • ej-shafran