Similar to JS optional chaining operator (?.) but is data driven and suitable to be use in configuration file.
pObj.dot(input, path, [value])
input: object, input can be either array or object
path: array, paths to reading a value from the input object. it supported multiple branching
value optional: any, default value if the path doesn't yeild any value from input
value yeild by the path in input or the default value
const input = [{name: 'Darren'}, {name: 'San'}]
pObj.dot(input, [1, 'name']) // return 'Darren'
pObj.dot(input, [2, 'name']) // return undefined
pObj.dot(input, [2, 'name'], 'NA') // return 'NA'with es6 module
import pCommon from 'pico-common'
const pObj = pCommon.export('pico/obj')with nodejs commonjs
const pObj = require('pico-common').export('pico/obj')with pico-common amd
const pObj = require('pico/obj')