check keys

This commit is contained in:
barisusakli
2014-09-06 01:04:20 -04:00
parent 779b2a8d73
commit a48e95b910
2 changed files with 18 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
"use strict";
var helpers = {};
var helpers = {},
winston = require('winston');
helpers.toMap = function(data) {
var map = {};
@@ -33,4 +34,16 @@ helpers.valueToString = function(value) {
helpers.noop = function() {};
helpers.checkKeys = function(keys) {
if (!Array.isArray(keys)) {
var e = new Error('invalid keys');
winston.warn('[INVALID_KEYS] ', e.stack);
return;
}
if (keys.length >= 50) {
var e = new Error('too many keys');
winston.warn('[TOO_MANY_KEYS] ' + keys.length + ' ' + keys[0] + ' ' + keys[keys.length - 1] + '\n', e.stack);
}
}
module.exports = helpers;