0.6.3 • Published 2 years ago

deepfinder v0.6.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Deepfinder

GitHub npm npm GA

Search attributes easily within structures of type dictionary, list and embedded substructures with simple format 'dict.users.0.name'.

Getting Started

Installation

  npm install deepfinder

Usage

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'
0.6.3

2 years ago

0.6.2

2 years ago

0.6.1

2 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.5

3 years ago

0.3.2

3 years ago

0.3.1

4 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.0

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.1.0

4 years ago

0.1.2

4 years ago

0.2.0

4 years ago

0.1.1

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago