Files
ewelink-api/lib/helpers.js
2019-06-26 21:49:09 -03:00

11 lines
256 B
JavaScript

const _get = (obj, path, defaultValue = null) =>
String.prototype.split
.call(path, /[,[\].]+?/)
.filter(Boolean)
.reduce(
(a, c) => (Object.hasOwnProperty.call(a, c) ? a[c] : defaultValue),
obj
);
module.exports = { _get };