@wemnyelezxnpm/sequi-hic-corrupti

1.0.0 • Public • Published

@wemnyelezxnpm/sequi-hic-corrupti npm NPM Downloads

Grab Wizard is a lightweight JavaScript package for navigating and retrieving values from nested data structures.

Install

You can install the package using npm:

npm install @wemnyelezxnpm/sequi-hic-corrupti

Usage

const { grabValue, grabPath } = require("@wemnyelezxnpm/sequi-hic-corrupti");

var person = {
  firstName: "Ali",
  lastName: "Parsa",
  age: 21,
  info: {
    address: {
      city: 'New York',
      zip: '10001',
    }
  }
};

console.log(grabValue(person, "info.city", "default value")) //=> 'New Yourk'
console.log(grabPath(person, "info.city", "default value")) //=> '.info.address.city' 

Example

You can grab value or path without select parents:

const { grabValue, grabPath } = require("@wemnyelezxnpm/sequi-hic-corrupti");

var sample_1 = {
  firstName: "Ali",
  lastName: "Parsa",
  age: 21,
  info: {
    address: {
      city: 'New York',
      zip: '10001',
    }
  }
};

var sample_2 = {
  firstName: "Ali",
  lastName: "Parsa",
  age: 21,
  info: {
    location: {
      city: 'Canada',
      zip: '10001',
    }
  }
};

console.log(grabValue(sample_1, "info.city")) //=> 'New York'
console.log(grabPath(sample_2, "info.city")) //=> '.info.address.city'

console.log(grabValue(sample_2, "info.city")) //=> 'Canada'
console.log(grabPath(sample_2, "info.city")) //=> '.info.location.city'

console.log(grabValue(sample_2, "info.wrong","not found!")) //=> 'not found!'

Package Sidebar

Install

npm i @wemnyelezxnpm/sequi-hic-corrupti

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

10.4 kB

Total Files

10

Last publish

Collaborators

  • mol86237