herrmanno/deep-obj-utils


Utilities to handle immutable objects without pain

https://herrmanno.github.io/deep-obj-utils/api

License: ISC

Language: TypeScript

Keywords: immutable, javascript, typescript


deep-obj-utils

deep-obj-utils is an utility library for modifieng (e. g. cloning) immutable objects while changing nested properties.

Installation

npm i deep-obj-utils

Examples

import { get, set, update } from "deep-obj-utils"

// retrieving nested values

const object = { foo: { bar: "baz" } }
get(["foo", "bar"], object) // "baz"

const object = [[null, "baz"]]
get([0, 1], object) // "baz"


// creating objects with changed nested properties

const object = { foo: { bar: "bar" } }
set(["foo", "bar"], object, "baz") // { foo: { bar: "baz" } }

const object = { foo: { bar: "bar" } }
update(["foo", "bar"], object, v => v.toUpperCase()) // { foo: { bar: "BAR" } }


// auto vivication

const object = {}
set(["foo", 0, "baz"], object, "baz") // { foo: ["baz", { bar: "BAR" }] }

Api

The documentation can be found at herrmanno.github.io/deep-obj-utils/api/.

This project is licensed under the ISC license.

Project Statistics

Sourcerank 4
Repository Size 212 KB
Stars 0
Forks 0
Watchers 1
Open issues 0
Dependencies 418
Contributors 2
Tags 5
Created
Last updated
Last pushed

Top Contributors See all

oherrmann92 herrmanno

Packages Referencing this Repo

deep-obj-utils
Utilities to handle immutable objects without pain
Latest release 1.0.0-rc.6 - Updated

Recent Tags See all

1.0.0-rc.5 March 24, 2018
1.0.0-rc.4 March 24, 2018
1.0.0-rc.3 March 24, 2018
1.0.0-rc.2 March 24, 2018
1.0.0-rc.1 March 23, 2018

Something wrong with this page? Make a suggestion

Last synced: 2019-05-15 09:30:13 UTC

Login to resync this repository