
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
tiny recursive utility to deal with keys/values of deeply nested objects
#deeputil
deeputil
is a tiny node.js module that provides a few recursive functions for dealing with keys/values of deeply nested objects.
###Install
npm i deeputil
###Docs
deeputil.key(obj)
obj
{Object}
@return
{String}
the property name of obj
const du = require('deeputil')
var someobj = {username: 'foo'}
console.log(du.key(someobj))
// result -> 'username'
deeputil.keys(obj)
obj
{Object}
@return
{Array<String>}
returns an array of all the keys of obj
no matter how deeply nested!
const du = require('deeputil')
var someobj = {
...
}
console.dir(du.keys(someobj))
deeputil.vals(obj)
obj
{Object}
@return
{Array<Object>}
returns an array of all the key/value pairs of obj
.
const du = require('deeputil')
var someobj = {
...
}
console.dir(du.vals(someobj))
deeputil.readStream(obj)
obj
{Object}
@return
{stream.Readable} a readable stream
data
{Object}
{key:'', val: }
streams all key/value pairs of obj
const du = require('deeputil')
var someobj = {
...
}
du.readStream(someobj).on('error', (err) => {
console.error(err)
}).on('data', (dat) => {
console.log('key:', dat.key)
console.log('value:', dat.val)
}).on('end', () => {
console.log('finished successfully.')
})
deeputil.find(obj, key)
obj
{Object}
key
{String}
the key to find its corresponding value
@return
{typeof found value | Array<typeof found value>}
if only one item found, returns the found value
if more than one item with the same key found (like in an array), returns an array of found values
const du = require('deeputil')
var someobj = {
data: [{username:'plugh', id: 17}, {username: 'thud', id: 92}],
baz: {
qux: {
garply: 'waldo',
quux: ['corge', 'grault']
}
}
}
console.log(du.find(someobj, 'qux'))
// result -> { garply: 'waldo', quux: [ 'corge', 'grault' ] }
console.log(du.find(someobj, 'garply'))
// result -> waldo
console.log(du.find(someobj, 'quux'))
// result -> [ 'corge', 'grault' ]
console.log(du.find(someobj, 'username'))
// result -> [ 'plugh', 'thud' ]
FAQs
tiny recursive utility to deal with keys/values of deeply nested objects
The npm package deeputil receives a total of 4 weekly downloads. As such, deeputil popularity was classified as not popular.
We found that deeputil demonstrated a not healthy version release cadence and project activity because the last version was released 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
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.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.