1.0.0 • Published 3 years ago

nv-facutil-object v1.0.0

Weekly downloads
7
License
ISC
Repository
-
Last release
3 years ago

nv-facutil-object

  • nv-facutil-object provide 4 simple functions for get/set/delete/set-default with pathlist
  • sometimes using dot o.x.y.u.z.... is boring if the object is very-big

install

  • npm install nv-facutil-object

usage

example

const {
    show,
    plset_dflt,
    plget,
    plset,
    pldel
} = require("./index")


> var o = plset_dflt({},['a','b','c','d','e'],100)
undefined
> show(o)
{
    "a": {
        "b": {
            "c": {
                "d": {
                    "e": 100
                }
            }
        }
    }
}
undefined
>

> plget(o,["a","b","c"])
{ d: { e: 100 } }
>

plset(o,['a','b','c','d','e'],999)
{ e: 999 }
> show(o)
{
    "a": {
        "b": {
            "c": {
                "d": {
                    "e": 999
                }
            }
        }
    }
}
undefined
>

> pldel(o,["a","b","c"])
{ a: { b: {} } }
>  show(o)
{
    "a": {
        "b": {}
    }
}
undefined
>

API

  • plget(o,pathlist)
  • plset(o,pathlist,v)
  • pldel(o,pathlist)
  • plset_dflt(o,pathlist,v)

LICENSE

  • ISC