smartenv/dist/smartenv.objectstorage.js

47 lines
3.5 KiB
JavaScript
Raw Normal View History

2016-04-04 16:24:22 +00:00
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
2016-11-21 10:58:37 +00:00
const plugins = require("./smartenv.plugins");
exports.obsItems = {};
/**
* Objectstorage allows easy sharing of objects within node
*/
2016-02-17 20:44:40 +00:00
exports.obs = {
2016-11-21 10:58:37 +00:00
add: function (paramNameArg = 'undefined', objectArg = 'undefined') {
if (paramNameArg === 'undefined') {
console.log('paramName is undefined');
2016-02-17 20:44:40 +00:00
return;
}
2016-11-21 10:58:37 +00:00
if (objectArg === 'undefined') {
console.log('objectArg is undefined');
2016-02-17 20:44:40 +00:00
}
2016-11-21 10:58:37 +00:00
if (typeof exports.obsItems[paramNameArg] === 'undefined') {
2016-02-17 20:44:40 +00:00
exports.obsItems[paramNameArg] = objectArg;
}
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
}
return exports.obsItems[paramNameArg];
},
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')) {
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) {
exports.obsItems = plugins.lodash.assign(exports.obsItems, itemsArg);
2016-02-17 20:44:40 +00:00
return exports.obsItems;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYub2JqZWN0c3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL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