
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
deeply-nested
Advanced tools
Get information about deeply nested keys in JavaScript objects and arrays
Get information about deeply nested keys in JavaScript objects and arrays
$ npm install deeply-nested
import { countKey, hasKey, findPaths, getValues } from "deeply-nested";
const { countKey, hasKey, findPaths, getValues } = require("deeply-nested");
import { countKey, hasKey, findPaths, getValues } from "deeply-nested";
const deeplyNestedObj = {
a: {
b: {
c: {
d: {
e: "e",
f: "f",
},
},
},
G: undefined,
aFunction: () => {
return true;
},
},
d: {
e: {
f: "F",
},
},
e: "Eeee",
};
// ** hasKey **
hasKey(deeplyNestedObj, "a");
// => true
hasKey(deeplyNestedObj, "x");
// => false
// ** countKey **
countKey(deeplyNestedObj, "a");
// => 1
countKey(deeplyNestedObj, "e");
// => 3
countKey(deeplyNestedObj, "x");
// => 0
// ** findPaths **
findPaths(deeplyNestedObj, "a");
// => [ 'a' ]
findPaths(deeplyNestedObj, "e");
// => [ 'e', 'a.b.c.d.e', 'd.e' ]
findPaths(deeplyNestedObj, "x");
// => []
// ** getValues **
getValues(deeplyNestedObj, "b");
// => [ { c: { d: [Object] } } ]
getValues(deeplyNestedObj, "e");
// => [ 'Eeee', 'e', { f: 'F' } ]
getValues(deeplyNestedObj, "G");
// => [ undefined ]
getValues(deeplyNestedObj, "aFunction");
// => [ [Function: aFunction] ]
getValues(deeplyNestedObj, "aFunction")[0]();
// => true
Returns: Boolean
Returns true or false depending on whether the key is found in the nested object.
Type: Object (or Array)
Type: String
hasKey(obj, "id"); // => true
Returns: Number
Returns the number of occurrences of the key in the nested object.
Type: Object (or Array)
Type: String
countKey(obj, "name"); // => 3
Returns: String[]
Returns an array of all the paths where the key occurs in the nested object, as dot-delimited strings (e.g., 'a.b.c.d.e').
Type: Object (or Array)
Type: String
findPaths(obj, "email");
// => [ 'employee.addresses[0].email', 'employee.addresses[1].email' ]
// The paths are `lodash.get` compatible:
import _ from "lodash";
const path = findPaths(obj, "provider");
// => [ 'user.profile.addresses[0].emails[0].provider'];
_.get(obj, path[0]);
// => 'gmail'
Returns: Any[]
Returns an array of all the values corresponding to the key's occurrences in the nested object.
Type: Object (or Array)
Type: String
getValues(obj, "age"); // => [ 25, 30, 45 ]
This library implementation is based on depth-first search algorithms I originally shared in my blog posts for confirming the existence of nested keys and finding their paths in JavaScript:
MIT © Talha Awan
FAQs
Get information about deeply nested keys in JavaScript objects and arrays
We found that deeply-nested 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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.