feature(binom) add

This commit is contained in:
coderaiser 2015-04-24 11:17:31 -04:00
parent 6b8235c002
commit 68114e5ac5
2 changed files with 30 additions and 3 deletions

27
lib/server/binom.js Normal file
View file

@ -0,0 +1,27 @@
(function() {
'use strict';
module.exports = binom;
function binom(name, array) {
var ret;
if (typeof name !== 'string')
throw(Error('name should be string!'));
if (!Array.isArray(array))
throw(Error('array should be array!'));
array.some(function(item) {
var is = item.name === name;
if (is)
ret = item;
return is;
});
return ret;
}
})();

View file

@ -15,8 +15,8 @@
path = require('path'),
root = require(DIR + 'root'),
binom = require(DIR + 'binom'),
Util = require(DIR_LIB + 'util'),
CloudFunc = require(DIR_LIB + 'cloudfunc'),
markdown = require(DIR + 'rest/markdown'),
@ -149,8 +149,8 @@
}
function auth(code, callback) {
var storage = Util.findObjByNameInArr(Modules, 'storage'),
gh = Util.findObjByNameInArr(storage, 'GitHub'),
var storage = binom(Modules, 'storage'),
gh = binom(storage, 'GitHub'),
env = process.env,
key = env.github_key || gh.key,