n8n-nodes-wuzapi
Version:
n8n community nodes for Wuzapi - WhatsApp Multi-Device REST API
69 lines • 2.12 kB
JavaScript
;
// Inline implementations to replace lodash functions
Object.defineProperty(exports, "__esModule", { value: true });
exports.set = set;
exports.get = get;
exports.isPlainObject = isPlainObject;
exports.unset = unset;
exports.isEmpty = isEmpty;
function set(obj, path, value) {
const pathArray = Array.isArray(path) ? path : path.split('.');
let current = obj;
for (let i = 0; i < pathArray.length - 1; i++) {
const key = pathArray[i];
if (!current[key] || typeof current[key] !== 'object') {
current[key] = {};
}
current = current[key];
}
current[pathArray[pathArray.length - 1]] = value;
return obj;
}
function get(obj, path, defaultValue) {
const pathArray = Array.isArray(path) ? path : path.split('.');
let current = obj;
for (const key of pathArray) {
if (current == null || typeof current !== 'object') {
return defaultValue;
}
current = current[key];
}
return current === undefined ? defaultValue : current;
}
function isPlainObject(value) {
if (!value || typeof value !== 'object') {
return false;
}
const prototype = Object.getPrototypeOf(value);
return prototype === null || prototype === Object.prototype;
}
function unset(obj, path) {
const pathArray = Array.isArray(path) ? path : path.split('.');
let current = obj;
for (let i = 0; i < pathArray.length - 1; i++) {
const key = pathArray[i];
if (!current[key] || typeof current[key] !== 'object') {
return false;
}
current = current[key];
}
const lastKey = pathArray[pathArray.length - 1];
if (lastKey in current) {
delete current[lastKey];
return true;
}
return false;
}
function isEmpty(value) {
if (value == null) {
return true;
}
if (typeof value === 'string' || Array.isArray(value)) {
return value.length === 0;
}
if (typeof value === 'object') {
return Object.keys(value).length === 0;
}
return false;
}
//# sourceMappingURL=lodashUtils.js.map