Created
June 18, 2016 10:20
-
-
Save shash7/10eb2d28b01593ad47f2ed75cbf44122 to your computer and use it in GitHub Desktop.
Global variables for nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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