
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Safely extract deeply nested properties – because safety is number one priority
A lightweight utility to safely dig into nested properties – because safety is number one priority.
To install diggs
:
npm install --save diggs
That's it!
diggs
?diggs allows you to access deeply nested properties without having to worry about undefined properties, null, or TypeErrors.
// Uncaught TypeError: Cannot read property 'foo' of null
// Uncaught TypeError: Cannot read property 'foo' of undefined
import { get } from 'diggs';
let data = {
a: {
b: {
c: ['foo', { d: 'bar' }],
}
},
z: null,
}
// retrieve deeply nested properties
get(data, 'a.b.c') // => ['foo', { d: 'bar' }]
// even array items
get(data, 'a.b.c[1].d') // => 'bar'
// returns undefined instead of throwing TypeErrors
get(data, 'z.a') // => undefined
// returns a default value
get(data, 'z.a', false) // => false
get(object, path, defaultValue)
Returns the value at the specified path
of object
. If the value is not found (undefined
), defaultValue will be returned instead.
object
(Object): The object to querypath
(String): The path of the property to getdefaultValue
] (Any): The value returned for undefined
valuesgit checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT
1.0.0
FAQs
Safely extract deeply nested properties – because safety is number one priority
The npm package diggs receives a total of 0 weekly downloads. As such, diggs popularity was classified as not popular.
We found that diggs 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.