SkillAgentSearch skills...

Bury

Safely set a dot-notated path within a nested object.

Install / Use

/learn @kalmbach/Bury
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

bury(obj, keypath, value)

Code Climate

Safely set a dot-notated path within a nested object, return undefined if the full key path does not exist, otherwise return the value set.

NPM

https://www.npmjs.com/package/bury

Usage

bury(object, keypath, value)

import bury from 'bury';

let obj = {
	a: {
		b: {
			c: 1
			d: undefined
			e: null
		}
	}
};

//use string dot notation for keys
bury(obj, 'a.b.c', 2) === 2;

//or use an array key
bury(obj, ['a', 'b', 'c'], 2) === 2;

//returns undefined if the full key path does not exist
bury(obj, 'a.b.c.f', "foo") === undefined;

Tests

https://github.com/kalmbach/bury/blob/master/test.js

License

MIT

Related Skills

View on GitHub
GitHub Stars82
CategoryDevelopment
Updated7mo ago
Forks4

Languages

JavaScript

Security Score

72/100

Audited on Aug 27, 2025

No findings