@jasonsbarr/dict
v0.11.0
Published
Functions that treat plain JS objects like iterable, immutable dictionaries
Downloads
5
Maintainers
Readme
@jasonsbarr/dict
A collection of functions that treat Plain Old JavaScript Objects as iterable, keyed collections (a.k.a. Dictionaries).
Note that returned objects will have a null
prototype. This is to give you the greatest flexibility with your allowable keys.
Basic Usage
Import and use only the functions you need:
import { filter } from "@jasonsbarr/dict/lib/filter";
import { endsWith } from "@jasonsbarr/functional-core/lib/string/endsWith";
const contacts = {
john: "[email protected]",
jimmy: "[email protected]",
jane: "[email protected]",
jeremy: "[email protected]",
};
const gmailContacts = filter(
(contact) => endsWith("@gmail.com", contact),
contacts
);