Package Exports
- deepfinder
- deepfinder/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (deepfinder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Deepfinder
Search attributes easily within structures of type dictionary, list and embedded substructures with simple format 'dict.users.0.name'.
Getting Started
Installation
npm install deepfinderUsage
Basic sample
const { deepFind } = require('deepfinder')
const user = {
name: 'ash',
links: {
pokehub: '@ash',
},
}
console.log(deepFind(user, 'links.pokehub'))
// output: '@ash'List sample
const { deepFind } = require('deepfinder')
const user = {
name: 'ash',
pokemons: [{
name: 'pikachu',
},{
name: 'charmander',
}],
}
console.log(deepFind(user, 'pokemons.0.name'))
// output: 'pikachu'List all result sample
const { deepFind } = require('deepfinder')
const user = {
name: 'ash',
pokemons: [{
name: 'pikachu',
},{
name: 'charmander',
}],
}
console.log(deepFind(user, 'pokemons.*.name'))
// output: ['pikachu', 'charmander']First not null path in list
const { deepFind } = require('deepfinder')
const user = {
name: 'ash',
pokemons: [{
name: 'pikachu',
},{
name: 'charmander',
ball: 'superball'
}],
}
console.log(deepFind(user, 'pokemons.?.ball'))
// output: 'superball'Use as js object native function
Disclaimer: use this useful, optional and dangerous practice at your own risk.
const DeepFinder = require('deepfinder')
DeepFinder.nativify()
const pokemon = { name: 'mew' }
console.log(pokemon.deepFind('name'))
// output: 'mew'