mirror of
https://github.com/skydiver/ewelink-api.git
synced 2025-12-24 06:28:30 +01:00
11 lines
256 B
JavaScript
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 };
|