From 550e2f03ad0b60b3c9db3d68dbf014dcb740a2ff Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Tue, 17 Jan 2017 15:37:25 +0530 Subject: Initial Commit --- src/global.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/global.js (limited to 'src/global.js') diff --git a/src/global.js b/src/global.js new file mode 100644 index 0000000..c837b44 --- /dev/null +++ b/src/global.js @@ -0,0 +1,31 @@ +//Global storage section +//global object stores data which is dependent on different modules +//to release an object from memory specify global.destroy("variablename") +define(['lodash'], function(_) { + + + var global = { + destroy: function(objectName) { + global[objectName] = null; + }, + destroyAll: function() { + var _keysExceptMethods = _.omitBy(global, function(value, key) { + return ( + _.eq(key, 'destroy') || + _.eq(key, 'destroyAll') || + _.eq(key, 'find') + ); + }); + + _.forEach(_keysExceptMethods, function(value, key) { + global[key] = null; + }) + }, + find: function(key) { + var pickedVar = _.pick(global, key); + return pickedVar; + } + } + + return global; +}); -- cgit v1.2.3