Functions for representing plain objects as typesafe immutable dictionaries
npm install ts-micro-dict




!Libraries.io dependency status for latest release


Functions for representing plain objects as typesafe immutable dictionaries
```
npm i ts-micro-dict
`typescript
import { Dict } from 'ts-micro-dict'
import { pipeWith } from 'pipe-ts'
const dict: Dict
// put
const putDict = Dict.put('y', 1, dict) // Dict
const putCurried = pipeWith(dict, Dict.put('y', 3)) // Dict
// omit
const omitDict = Dict.omit('x', dict) // Dict
const omitCurried = pipeWith(dict, Dict.omit('x')) // Dict
// filter
const filterDict = Dict.filter((item, key) => true, dict) // Dict
const filterCurried = pipeWith(
dict,
Dict.filter((item, key) => true)
) // Dict
// map
const mapDict = Dict.map((item, key) => true, dict) // Dict
const mapCurried = pipeWith(
dict,
Dict.map((item, key) => true)
) // Dict
// reduce
const reduceDict = Dict.reduce((acc, item, key) => acc + item, 0, dict) // number
const reduceCurried = pipeWith(
dict,
Dict.reduce((acc, item, key) => acc + item, 0)
) // number
// some
const someDict = Dict.some((item, key) => true, dict) // boolean
const someCurried = pipeWith(
dict,
Dict.some((item, key) => true)
) // boolean
// every
const everyDict = Dict.every((item, key) => true, dict) // boolean
const everyCurried = pipeWith(
dict,
Dict.every((item, key) => true)
) // boolean
// toArray
const toArray = Dict.toArray((item, key) => [key, item], dict) // readonly (readonly [string, number])[]
const toArrayCurried = pipeWith(
dict,
Dict.toArray((item, key) => [key, item])
) // readonly (readonly [string, number])[]
// fromArray
const array: number[] = [1, 2, 3]
const fromArray = Dict.fromArray((value, index) => [${index}, value], array) // Dict${index}
const fromArrayCurried = pipeWith(
array,
Dict.fromArray((value, index) => [, value])
) // Dict
// length
const length = Dict.length(dict) // number
// isEqual
const isEqual = Dict.isEqual(dict, { y: 2 }, (a, b) => a === b) // false˜
``