Skip to content

Instantly share code, notes, and snippets.

@shash7
Created June 18, 2016 10:20
Show Gist options
  • Save shash7/10eb2d28b01593ad47f2ed75cbf44122 to your computer and use it in GitHub Desktop.
Save shash7/10eb2d28b01593ad47f2ed75cbf44122 to your computer and use it in GitHub Desktop.
Global variables for nodejs
/* jslint undef: true */
/* global window, document, $ */
/* ----------------------------------------------------------------
* globals.js
*
* Contains setters and getters to store and retrieve global vars
* ---------------------------------------------------------------- */
(function() {
'use strict';
var _ = require('underscore');
var arr = [];
module.exports = {
arr : [],
get : function(name) {
var result = null;
this.arr.map(function(item) {
if(name === item.name) {
result = item.data;
}
});
return result;
},
set : function(name, obj) {
this.arr.push({
name : name,
data : obj
});
},
remove : function(name) {
var result = [];
this.arr = this.arr.map(function(item) {
if(name !== item.name) {
result.push(item);
}
});
this.arr = result;
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment