mirror of
https://github.com/skydiver/ewelink-api.git
synced 2025-12-24 06:28:30 +01:00
added helpers lib
This commit is contained in:
10
lib/helpers.js
Normal file
10
lib/helpers.js
Normal file
@@ -0,0 +1,10 @@
|
||||
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 };
|
||||
Reference in New Issue
Block a user