[TASK] Add src/Tools.js containing small helper functions.

This commit is contained in:
Jan Philipp Timme 2013-09-15 13:45:54 +02:00
parent f63afa6c10
commit eecbca2907
1 changed files with 13 additions and 0 deletions

13
src/Tools.js Normal file
View File

@ -0,0 +1,13 @@
//check whether all given params exist in an object
//var success = .reqParamsGiven(["username", "password"], req.body);
exports.reqParamsGiven = function (keys, obj) {
if(typeof(obj) != "object" || obj.length < 1) return false;
for(k in keys) {
var key = keys[k];
var value = obj[key];
if(value == undefined) {
return false;
}
}
return true;
}