Gathering detailed insights and metrics for dash-get
Gathering detailed insights and metrics for dash-get
Gathering detailed insights and metrics for dash-get
Gathering detailed insights and metrics for dash-get
npm install dash-get
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3 Stars
22 Commits
1 Watching
2 Branches
1 Contributors
Updated on 05 Dec 2023
TypeScript (97.96%)
JavaScript (2.04%)
Cumulative downloads
Total Downloads
Last day
-10.1%
38,726
Compared to previous day
Last week
-0.7%
209,678
Compared to previous week
Last month
0.9%
925,467
Compared to previous month
Last year
41.4%
20,467,053
Compared to previous year
5
A tiny get function', similar to Lodash.get
Add dash-get
to your project via npm install
:
npm install --save dash-get
You can easily retrieve a value from a (deeply) nested object with dash-get
, like so:
1import get from 'dash-get' 2 3const someObject = {...} 4 5const deeplyNestedValue = get(someObject, 'the.path.to.the.nested.value') 6// value
The path could also be an Array
:
1const someObject = {...} 2 3const deeplyNestedValue = get(someObject, ['the', 'path', 'to', 'the', 'nested', 'value']) 4// value
get(obj, path, fallback)
Argument | Type | Description |
---|---|---|
obj | Object | The object to get the value from. |
path | Array<string> /string | The path to the value. |
fallback | any | The fallback value, in case the desired value could not be retrieved. |
This module does not support this particular use case:
get(object, 'a[0].b.c')
You totally don't have to npm install
this. This exists for convenience purposes 😊.
In fact, it's encouraged that you add the get
code to your code base! One less depenency to install and manage.
Here it is!
1function get(obj, path, fallback) { 2 if (!obj || !path) return fallback; 3 const paths = Array.isArray(path) ? path : path.split("."); 4 let results = obj; 5 let i = 0; 6 7 while (i < paths.length && results !== undefined && results !== null) { 8 results = results[paths[i]]; 9 i++; 10 } 11 12 if (i === paths.length) { 13 return results !== undefined ? results : fallback; 14 } 15 16 return results !== undefined && results !== null ? results : fallback; 17}
Thanks to @knicklabs for pairing with me on this one!
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
61 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More