1.0.2 • Published 3 years ago

gettools v1.0.2

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

Gettools

This package includes an functions manager from data json in object and array from getting data, avoiding them null results or undefined

Installation

npm install -g gettools

Example getData

import { getData } from 'gettools'

const data = {
  _id: '1',
  name: 'Cesar'
}

const name = getData(data, 'name', '');
// Cesar

const name = getData(data, 'lastname', 'Not lastname');
// Not lastname

Example getRow

import { getRow } from 'gettools'

const data = [
  {_id: '1', name: 'Cesar'},
  {_id: '2', name: 'Lucas'}
]

const name = getRow(data, 0, 'name', '');
// Cesar

const name = getRow(data, 0, 'lastname', 'Not lastname');
// Not lastname

Example getSource

import { getSource } from 'gettools'

const data = {
  _id: '1',
  name: {
    first_name: 'Cesar'
  }
}

const name = getSource(data, ['name', 'first_name'], '');
// Cesar

const name = getSource(data, ['name', 'last_name'], 'Not lastname');
// Not lastname
1.0.2

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago