
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
js-object-utilities
Advanced tools
This package has a bunch of helper methods to work with nested objects in JavaScript.
npm i js-object-utilities
This function takes in an object (obj
) and a key (key
) and returns the value for the given key.
const objectutils = require("js-object-utilities");
console.log(objectutils.get({
"data": {
"hello": "world"
}
}, "data.hello"));
// Will print "world"
This function takes in an object (obj
), key (key
), and a value (value
) and mutates the object setting the value for the given key.
const objectutils = require("js-object-utilities");
const object = {
"data": {
"hello": "world"
}
};
objectutils.set(object, "data.hello", "universe");
console.log(object); // {"data": {"hello": "universe"}}
This function takes in an object (obj
), and key (key
), and deletes the given value for the key you passed in.
const objectutils = require("js-object-utilities");
const object = {
"data": {
"hello": "world"
}
};
objectutils.delete(object, "data.hello");
console.log(object); // {"data": {}}
This function takes in an object (obj
), and array of keys (keys
), and returns an object for the given keys you passed in.
const objectutils = require("js-object-utilities");
const object = {
"data": {
"hello": "world",
"space": "travel",
"node": "npm"
}
};
objectutils.delete(object, ["data.hello", "data.space"]);
console.log(object); // {"data": {"hello": "world", "space": "travel"}}
This function takes in an object (obj
), and returns an array of keys included in that object.
const objectutils = require("js-object-utilities");
const object = {
"data": {
"hello": "world",
"space": "travel",
"node": "npm"
}
};
console.log(objectutils.keys(object)); // ["data", "data.hello", "data.space", "data.node"]
This function takes in an object (obj
), and returns an array of entries included in that object.
const objectutils = require("js-object-utilities");
const object = {
"data": {
"hello": "world",
"space": "travel",
"node": "npm"
}
};
console.log(objectutils.keys(object)); // [["data", {"hello": "world", "space": "travel", "node": "npm"}], ["data.hello", "world"], ["data.space", "travel"], ["data.node", "npm]]
This function takes in two values, and returns a boolean representing if they are equal. If objects as passed in it will check to ensure the entire object is identical.
const objectutils = require("js-object-utilities");
const object = {
"data": {
"hello": "world",
"space": "travel",
"node": "npm"
}
};
console.log(objectutils.equals(object, {
"data": {
"hello": "world",
"space": "travel",
"node": "npm"
}
})); // true
console.log(objectutils.equals(object, {
"data": {
"hello": "universe",
"space": "travel",
"node": "npm"
}
})); // false
This function takes in an object and mutates it to remove all objects with a length of 0.
const objectutils = require("js-object-utilities");
const object = {
"data": {
"hello": "world",
"space": "travel",
"node": "npm",
"otherData": {}
}
};
objectutils.clearEmpties(object);
console.log(object);
// {
// "data": {
// "hello": "world",
// "space": "travel",
// "node": "npm",
// }
// }
This function checks to see if an object is circular. If a search key is passed in it will only return true
if the object is circular and the search key is the key that caused the circularity.
This function will also check all nested objects for circularity.
const objectutils = require("js-object-utilities");
let object = {};
object.array = {"first": 1};
object.array2 = object;
const isCircular = objectutils.isCircular(object);
console.log(isCircular); // true
const isRandomKeyCircular = objectutils.isCircular(object, "random");
console.log(isRandomKeyCircular); // false
const isArray2KeyCircular = objectutils.isCircular(object, "array2");
console.log(isArray2KeyCircular); // true
This function is identical to objectutils.isCircular
except it returns an array of keys that are circular.
const objectutils = require("js-object-utilities");
let object = {};
object.array = {"first": 1};
object.array2 = object;
const circularKeys = objectutils.circularKeys(object);
console.log(circularKeys); // ["array2"]
const randomKeyCircular = objectutils.circularKeys(object, "random");
console.log(randomKeyCircular); // []
const array2KeyCircular = objectutils.circularKeys(object, "array2");
console.log(array2KeyCircular); // ["array2"]
FAQs
JavaScript utilities for nested objects
The npm package js-object-utilities receives a total of 84,299 weekly downloads. As such, js-object-utilities popularity was classified as popular.
We found that js-object-utilities demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.