@util-funcs/object-get
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

object-get

Deep dive into plain object and take value by key chaining.

npm version Build Status

Getting Started

import get from '@util-funcs/object-get';

Installing

npm i @util-funcs/object-get --save

or

yarn add @util-funcs/object-get

Examples

const data = {
  name: 'John',
  surname: 'Doe',
  age: 34,
  location: {
    city: 'Londra',
    country: 'UK',
  },
  orders: [
    {
      name: 'Headphone',
      price: 45.6,
      type: 'electronic',
    },
    {
      name: 'Macbook Air 13.3 inch',
      price: 45.6,
      type: 'electronic',
    },
  ],
  '#hobbies': ['travel', 'edm'],
};
  get('name', data)) === 'John'

  get('location.city', data) === 'Londra'

  get('#hobbies[0]', data) === 'travel'

  get('orders[0]name', data) === 'Headphone'

  get('orders[0]name.length', data) === 9

  get('orders[0]category', data, 'uncategorized') === 'uncategorized'

Run tests

npm test

Built With

Versioning

We use SemVer for versioning.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Dependencies (0)

    Dev Dependencies (8)

    Package Sidebar

    Install

    npm i @util-funcs/object-get

    Weekly Downloads

    8

    Version

    0.0.2

    License

    MIT

    Unpacked Size

    4.83 kB

    Total Files

    6

    Last publish

    Collaborators

    • atayahmet