uinix-fp-filter-entries
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

uinix-fp-filter-entries

Build Coverage Downloads Size

uinix-fp object filter entries utility.


Install

This package is ESM-only and requires Node 12+.

npm install uinix-fp-filter-entries

Use

filterEntries applies the provided filter predicate over an object's entries. It is recommended that the provided objects follow a single value interface when using with filterEntries.

import {filterEntries} from 'uinix-fp-filter-entries';

const isEvenEntries = ([_k, v]) => v % 2 === 0;

filterEntries(isEvenEntries)({a: 1, b: 2, c: 3}); // {b: 2}

const filterEvenEntries = filterEntries(isEvenEntries); // curried
filterEvenEntries({a: 1, b: 2, c: 3}); // {b: 2}

const keyedIsEvenEntries = ([k, v]) => k.startsWith('a') ? v % 2 === 0 : false;
filterEntries(keyedIsEvenEntries)({a1: 2, b1: 3, a2: 5, b2: 6}); // {a1: 2}

API

This package exports the following identifiers: filterEntries. There is no default export.

filterEntries(f)(object)

Parameters (Curried)
  • f ((x: X) => boolean): The filter predicate function.
  • object (Record<string, X>): An object with values of a single type.
Returns
  • Record<string, X> — Partial object of filtered entries passing the predicate test.

License

MIT © Chris Zhou

Package Sidebar

Install

npm i uinix-fp-filter-entries

Weekly Downloads

9

Version

1.0.1

License

MIT

Unpacked Size

3.83 kB

Total Files

4

Last publish

Collaborators

  • chrisrzhou