0.0.11 • Published 6 years ago

@mzvonar/getin v0.0.11

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

getIn Build Status Coverage Status npm version

Get value from object by path. Path can be string or array (e.g. 'user', 'profile', 'gender').
If any value in path is undefined then undefined is returned or defaultValue if provided.

Installation

npm install @mzvonar/getin

Usage

const getIn = require('@mzvonar/getin');
  
const context = {
    user: {
        profile: {
            gender: 'female'
        }
    }
};
  
const gender = getIn(context, ['user', 'profile', 'gender']);

gender is female

const country = getIn(context, ['user', 'address', 'country']);

country is undefined

const verified = getIn(context, ['user', 'profile', 'verified'], false);

verified is false

Tests

npm test

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago