2016-04-04 16:24:22 +00:00
|
|
|
"use strict";
|
2017-04-19 18:02:43 +00:00
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
2016-11-21 10:58:37 +00:00
|
|
|
const plugins = require("./smartenv.plugins");
|
2017-04-19 18:02:43 +00:00
|
|
|
exports.obsItems = {};
|
|
|
|
/**
|
|
|
|
* Objectstorage allows easy sharing of objects within node
|
|
|
|
*/
|
2016-02-17 20:44:40 +00:00
|
|
|
exports.obs = {
|
2017-04-20 22:04:28 +00:00
|
|
|
add: (keyNameArg, objectArg) => {
|
|
|
|
if (!keyNameArg) {
|
|
|
|
console.log('keyName is undefined');
|
2016-02-17 20:44:40 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-04-20 22:04:28 +00:00
|
|
|
if (!objectArg) {
|
2016-11-21 10:58:37 +00:00
|
|
|
console.log('objectArg is undefined');
|
2016-02-17 20:44:40 +00:00
|
|
|
}
|
2017-04-20 22:04:28 +00:00
|
|
|
if (!(exports.obsItems[keyNameArg])) {
|
|
|
|
exports.obsItems[keyNameArg] = objectArg;
|
2016-02-17 20:44:40 +00:00
|
|
|
}
|
|
|
|
else {
|
2016-11-21 10:58:37 +00:00
|
|
|
console.log('object is already present, so add operation has failed.');
|
2016-02-17 20:44:40 +00:00
|
|
|
}
|
2017-04-20 22:04:28 +00:00
|
|
|
return exports.obsItems[keyNameArg];
|
2016-02-17 20:44:40 +00:00
|
|
|
},
|
|
|
|
replace: function (paramNameArg, objectArg) {
|
|
|
|
exports.obsItems[paramNameArg] = objectArg;
|
|
|
|
},
|
|
|
|
merge: function (paramNameArg, objectArg) {
|
2016-11-21 10:58:37 +00:00
|
|
|
if (!(typeof exports.obsItems[paramNameArg] === 'undefined')) {
|
2017-04-19 18:02:43 +00:00
|
|
|
exports.obsItems[paramNameArg] = plugins.lodash.assign(exports.obsItems[paramNameArg], objectArg);
|
2016-02-17 20:44:40 +00:00
|
|
|
}
|
|
|
|
else {
|
2016-11-21 10:58:37 +00:00
|
|
|
console.log('object is not present, so there is nothing to merge');
|
2016-02-17 20:44:40 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
get: function (keyName) {
|
|
|
|
return exports.obsItems[keyName];
|
|
|
|
},
|
|
|
|
getAll: function () {
|
|
|
|
return exports.obsItems;
|
|
|
|
},
|
|
|
|
addComplete: function (itemsArg) {
|
2017-04-19 18:02:43 +00:00
|
|
|
exports.obsItems = plugins.lodash.assign(exports.obsItems, itemsArg);
|
2016-02-17 20:44:40 +00:00
|
|
|
return exports.obsItems;
|
|
|
|
}
|
|
|
|
};
|
2017-04-20 22:04:28 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYub2JqZWN0c3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52Lm9iamVjdHN0b3JhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSw4Q0FBOEM7QUFFbkMsUUFBQSxRQUFRLEdBQVEsRUFBRSxDQUFBO0FBRTdCOztHQUVHO0FBQ1EsUUFBQSxHQUFHLEdBQVE7SUFDcEIsR0FBRyxFQUFFLENBQUMsVUFBVSxFQUFFLFNBQVM7UUFDekIsRUFBRSxDQUFDLENBQUMsQ0FBQyxVQUFVLENBQUMsQ0FBQyxDQUFDO1lBQ2hCLE9BQU8sQ0FBQyxHQUFHLENBQUMsc0JBQXNCLENBQUMsQ0FBQTtZQUNuQyxNQUFNLENBQUE7UUFDUixDQUFDO1FBQ0QsRUFBRSxDQUFDLENBQUMsQ0FBQyxTQUFTLENBQUMsQ0FBQyxDQUFDO1lBQ2YsT0FBTyxDQUFDLEdBQUcsQ0FBQyx3QkFBd0IsQ0FBQyxDQUFBO1FBQ3ZDLENBQUM7UUFDRCxFQUFFLENBQUMsQ0FBQyxDQUFDLENBQUMsZ0JBQVEsQ0FBRSxVQUFVLENBQUUsQ0FBQ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