0.1.4 • Published 7 years ago

squba v0.1.4

Weekly downloads
145
License
MIT
Repository
github
Last release
7 years ago

squba

XO code style

Safely access deeply nested properties.

Install

npm i -S squba

or

npm i -S squba

Use

import squba from 'squba'
// OR
const squba = require('squba')

const foo = {
  bar: {
    arr: ['a', 'b', 'c'],
    objs: [ { name: 'Mike', address: { street: 'Lemontree st.' } } ]
  }
}

squba(foo, ['bar', 'objs', 0, 'name']) // 'Mike'
squba(foo, 'bar.objs.0.name') // 'Mike'

squba(foo, ['bar', 'objs', 0, 'address', 'street']) // 'Lemontree st.'
squba(foo, 'bar.objs.0.address.street') // 'Lemontree st.'

squba(foo, ['bar', 'arr', 4]) // undefined
squba(foo, 'bar.arr.4') // undefined

squba(foo, ['bar', 'baz']) // undefined
squba(foo, 'bar.baz') // undefined

FAQ