![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
find-object-paths
Advanced tools
Find paths in objects to given key('s), value('s) or key/value combinations
Easy to use zero dependency get or find paths in objects to given key('s), value('s) or key/value combinations. It is meant to interact nicely with lodash to quickly access or test values in objects, but can be used standalone as well.
Despite other projects you also can specify values to be searched for.
Install via npm
npm install findObjectPaths
acmeInc.json
{
"company": {
"name": "ACME INC",
"address": "1st Street, Toontown, TT",
"founded": "December 31st 1969",
"hasStocks": true,
"numberOfEmployees": 2,
"numberOfActors": 3
}
// see full content on github
}
import { has, findObjectPaths } from 'findObjectPaths';
class TestMe {
static async main() {
let acmeInc = {};
rawFileContent = fs.readFileSync(p.resolve(__dirname, 'acmeInc.json'), 'utf-8');
acmeInc = JSON.parse(rawFileContent);
let path = findObjectPaths(acmeInc, {key: 'founded'});
// company.founded
path = findObjectPaths(acmeInc, {value: 'December 31st 1969'});
// company.founded
const allPaths: string[] = findObjectPaths(acmeInc, {key: 'actorId'}) as string[];
/* [ 'actors[0].actorId',
'actors[1].actorId',
'actors[2].actorId',
'actors[3].actorId' ]
*/
const ceoPath = findObjectPaths(acmeInc, {key: 'isCEO', value: true});
// employees[0].isCEO
has(acmeInc, 'name', 'Hugo Boss');
// true
has(acmeInc, {value: 'Hugo Boss'});
// true
}
}
TestMe.main();
See more examples implemented in tests-findObjectPaths.
findObjectPaths can be used as a lodash mixin.
import _ from '../lib/FindObjectPathsMixin';
.
.
.
const path = _.findObjectPaths(acmeInc, {key: 'numberOfActors'});
// company.numberOfActors
path = _.findObjectPaths(acmeInc, {value: 'DVD'});
// distributionChannels[1][2]
if (_.has(acmeInc, _.findObjectPaths(acmeInc, {value: 'DVD'}))) {
const dvd = _.get(acmeInc, _.findObjectPaths(acmeInc, {value: 'DVD'}));
// do something
}
Tests can be found in /test
and run by jest. To run the tests call npm test
.
has
function to check availability of keys / values in objects or arraysFAQs
Find paths in objects to given key('s), value('s) or key/value combinations
The npm package find-object-paths receives a total of 2,378 weekly downloads. As such, find-object-paths popularity was classified as popular.
We found that find-object-paths 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.