1.1.2 • Published 12 days ago

@teamteanpm2024/placeat-nemo-rerum v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

@teamteanpm2024/placeat-nemo-rerum

Set and get values on objects via dot-notation strings.

Example

var deep = require('@teamteanpm2024/placeat-nemo-rerum');

var obj = {
  foo: {
    bar: 'baz',
    'bar.baz': 'qux'
  }
};

// Get
console.log(deep(obj, 'foo.bar'));
  // => "baz"

// Get with array
console.log(deep(obj, ['foo', 'bar.baz']));
  // => "qux"

// Set
deep(obj, 'foo.bar', 'hello');
console.log(obj.foo.bar);
  // => "hello"

// Set with array
deep(obj, ['foo', 'bar.baz'], 'goodbye');
console.log(obj.foo['bar.baz']);
  // => "goodbye"

API

deep(object, path, value)

Where path is a dot-notation string foo.bar or an array of strings.

  • If value is passed it will be set on the path.
  • Set deep.p = true if you want non-existent paths to be initialized.
  • If you want to unset (or delete), pass undefined as the value.

Installation

With npm do:

npm install @teamteanpm2024/placeat-nemo-rerum

Note

There's a dozen modules like this on npm. This is a fork from @juliangruber's deep-access module, with a big portion of code directly copied from here: https://github.com/substack/js-traverse/blob/master/index.js#L11-L18.

Similar modules:

License

MIT

io-tsjsdiffArray.prototype.findLastIndexdebuggersyntaxassertionPromiseiteratoroperating-systemECMAScript 3real-timettyvaluesxdgbundlingshellstylesheetopentoobjectstylesCSSshimvestinvariantpatchquerystringqueueMicrotaskinterruptstacitRegExp#flagspromiseES2022propertiesrmdires7eventEmitterrobusttoolkitmobiledeterministiccircularsafebannercopyes2015Symbol.toStringTagcodesanimationrateArray.prototype.findLastlistenersfseventsfromlruchecklesscssargvhandlersnested cssfigletArray.prototype.filterdirectoryjson-schemalogutilsterminalpackage managersignalsharmonyiswatchFileIteratorslotsetinstallerwgetobjecttrimRightmakeredux-toolkitUint8ArraycurrieduninstallflagredactpushlimitgroupByfast-deep-clonehookscjkeditorInt16ArrayglobES8css nestingObservablesframercompilertoStringTagfast-copyes-shimstoArraymkdirsrm -frestreeECMAScript 2015protobufspawnconstcss lesswaapitypedidworkspace:*Uint16Arrayregular expressionsArray.prototype.flattenfindeveryMicrosoftloadingreadablestreamirqconfigurablemiddlewarefindup__proto__util.inspectFloat32ArraydescriptionthreejestapiSetECMAScript 2020inputreact-hooksdescriptorslookbrowserslistcall-bindwraptypescriptequalityenumerableArrayES2017classnamesrfc4122stablecollectionvalidateinferenceresolvegradients css3pyyamleast-asian-widthECMAScript 2022erroremiteslintArray.prototype.includesbufferstartJSON-SchemagrouptypesstreamgdprstructuredClonedeeperror-handlingcensorfindLastassertswatchconsoletddupassertkoreanduplexRFC-6455i18nvarcommandfunctionoutputfetchfastcloneimmutableES2021unicodeargparsecolormkdirpimportreuseYAML
1.1.1

13 days ago

1.1.2

12 days ago

1.0.1

14 days ago

1.0.0

15 days ago