UNPKG

strong-map

Version:

[![License](https://img.shields.io/npm/l/strong-map.svg)](https://img.shields.io/npm/l/strong-map.svg) [![Build Status](https://travis-ci.org/jorma16/strong-map.svg?branch=master)](https://travis-ci.org/jorma16/strong-map) [![Coverage Status](https://cove

23 lines (17 loc) 431 B
const fns = require('./utils/fn'); class StrongMap extends Map { get(...args) { const [k] = args; if (k instanceof Object) { const key = [...this.keys()].find((k2) => fns.equals(k, k2)); return super.get(key); } return super.get(...args); } getTruthyKeys() { return [...this.entries()] .filter(([, allowed]) => allowed) .map(([key]) => key); } } module.exports = StrongMap;