smartenv/dist/smartenv.objectstorage.js

43 lines
3.3 KiB
JavaScript

"use strict";
const plugins = require("./smartenv.plugins");
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._.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._.assign(exports.obsItems, itemsArg);
return exports.obsItems;
}
};
exports.obsItems = {};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYub2JqZWN0c3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52Lm9iamVjdHN0b3JhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLDhDQUE4QztBQUNuQyxRQUFBLEdBQUcsR0FBUTtJQUNsQixHQUFHLEVBQUUsVUFBUyxZQUFZLEdBQUcsV0FBVyxFQUFDLFNBQVMsR0FBRyxXQUFXO1FBQzVELEVBQUUsQ0FBQyxDQUFDLFlBQVksS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDO1lBQy9CLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQTtZQUNyQyxNQUFNLENBQUE7UUFDVixDQUFDO1FBQ0Q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