smartenv/dist/smartenv.objectstorage.js

47 lines
3.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartenv.plugins");
exports.obsItems = {};
/**
* Objectstorage allows easy sharing of objects within node
*/
exports.obs = {
add: function (paramNameArg = 'undefined', objectArg = 'undefined') {
if (paramNameArg === 'undefined') {
console.log('paramName is undefined');
return;
}
if (objectArg === 'undefined') {
console.log('objectArg is undefined');
}
if (typeof exports.obsItems[paramNameArg] === 'undefined') {
exports.obsItems[paramNameArg] = objectArg;
}
else {
console.log('object is already present, so add operation has failed.');
}
return exports.obsItems[paramNameArg];
},
replace: function (paramNameArg, objectArg) {
exports.obsItems[paramNameArg] = objectArg;
},
merge: function (paramNameArg, objectArg) {
if (!(typeof exports.obsItems[paramNameArg] === 'undefined')) {
exports.obsItems[paramNameArg] = plugins.lodash.assign(exports.obsItems[paramNameArg], objectArg);
}
else {
console.log('object is not present, so there is nothing to merge');
}
},
get: function (keyName) {
return exports.obsItems[keyName];
},
getAll: function () {
return exports.obsItems;
},
addComplete: function (itemsArg) {
exports.obsItems = plugins.lodash.assign(exports.obsItems, itemsArg);
return exports.obsItems;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYub2JqZWN0c3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52Lm9iamVjdHN0b3JhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSw4Q0FBOEM7QUFFbkMsUUFBQSxRQUFRLEdBQVEsRUFBRSxDQUFBO0FBRTdCOztHQUVHO0FBQ1EsUUFBQSxHQUFHLEdBQVE7SUFDcEIsR0FBRyxFQUFFLFVBQVUsWUFBWSxHQUFHLFdBQVcsRUFBRSxTQUFTLEdBQUcsV0FBVztRQUNoRSxFQUFFLENBQUMsQ0FBQyxZQUFZLEtBQUssV0FBVyx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