0.1.1 • Published 1 year ago
@bearclaw/collections v0.1.1
collections
This library is a set of TypeScript classes and functions for working with collections of data.
HashMap
An extension of the built-in Map object that uses a hashing function for key equality. Unlike the built-in Map object, it will treat objects with identical values as equal. To illustrate this difference, this is how the built-in Map treats objects:
const map = new Map()
map.set({}, 'abc')
map.get({}) // Will return undefined
map.has({}) // Will return falseIn contrast, HashMap will treat them like so:
const map = new HashMap()
map.set({}, 'abc')
map.get({}) // Will return `'abc'`
map.has({}) // Will return trueHashSet
An extension of the built-in Set object that uses a hashing function for value equality. Unlike the built-in Set object, it will treat identical object values as equal. To illustrate this difference, this is how the built-in Set treats objects:
const set = new Set()
map.add({})
map.has({}) // Will return falseIn contrast, HashSet will treat them like so:
const set = new HashSet()
map.add({})
map.has({}) // Will return trueRunning unit tests
Run nx test collections to execute the unit tests via Jest.