Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var insert = function (cultures) {
// iterate through cultures
async.forEach(cultures, function (culture, _callback) {
// name is required
if (!culture.hasOwnProperty('name')) {
_callback();
return;
}
culture = module.exports.matchToModel(culture);
if(module.exports.policy == 1) { // empty db, so just add it
addCulture(culture, function(suc){ _callback(); });
}
else {
// see if there is such an entry already in the db
Cultures.getByName(culture.name,function(success,oldCulture){
if(success == 1) { // old entry is existing
var isChange = false;
findAllResources : function(callback) {
var t = this;
var db = this.__db;
if (!db.resources)
db.resources = {};
// Scan all teh libraries
async.forEach(t.__libraries,
function(library, callback) {
var resources = db.resources[library.libraryName];
if (!resources)
db.resources[library.libraryName] = resources = {};
var rootDir = path.join(library.rootDir, library.resourcePath);
var tasks = [];
// Scans a folder, recursively, looking for resource files
function scanDir(dir, callback) {
// Get the list of files
fs.readdir(dir, function(err, files) {
if (err)
return callback(err);
// and process each one
function compileCoffee() {
async.forEach(files, function(file, callback) {
if (file.language != 'coffee') {
callback();
return;
}
var coffeeScript = require('coffee-script');
file.content = coffeeScript.compile(file.content, {filename: file.path});
callback();
}, function(err) {
if (err) {
console.error(clc.red('Converting ' + err + ' to JavaScript failed.'));
process.exit(1);
}
function writeBundleJavascripts(name, tmpdir, sandbox, assets, callback) {
async.forEach(N.config.locales["enabled"], function (locale, next) {
var
javascript = "",
filename = path.join(tmpdir, "bundle", name + "." + locale + ".js");
_.each(assets, function (data) {
javascript += data.javascripts[locale];
});
sandbox.assets.files.push(filename);
fs.writeFile(filename, javascript, "utf8", callback);
}, callback);
}
if (bundleType === 'both') {
filePathsToDelete.push(tarballPath);
filePathsToDelete.push(extractedPath);
}
else if (bundleType === 'tarball') {
filePathsToDelete.push(tarballPath);
}
else if (bundleType === 'extracted') {
filePathsToDelete.push(extractedPath);
}
else {
http.returnError(res, 400, sprintf('Invalid bundle type: %s', bundleType));
return;
}
async.forEach(filePathsToDelete, deleteBundlePath, function(err) {
if (err) {
errMsg = err.message;
statusCode = (err.errno === constants.ENOENT) ? 404 : 400;
http.returnError(res, statusCode, err);
return;
}
res.writeHead(204, {});
res.end();
});
}
var getValidUrls = Sources.getValidUrls = function(sources, cb) {
var validUrls = [];
async.forEach(sources, function(source, cb) {
getValidUrl(source, function(u) {
if (u) {
validUrls.push(u);
}
cb();
});
}, function() {
var err = null;
if (validUrls.length === 0) {
err = '没有找到合法的网路服务 (' + sources + ').';
}
cb(err, validUrls);
});
};
function (data) {
require('fs').writeFile("./test/tweets.json",
JSON.stringify(data));
async.forEach(data,
function (tweet, callback) {
basil.get_pic_link(tweet, function (url) {
if (url) {
tweet.image_link = url;
tweet.image_url = '';
users[userId].now.show_tweets([tweet]);
}});
callback(null);
},
function () {
res.end();
});
});
});
var cacheConfig = function(cb) {
var config = new Config();
var configJson = path.join(process.cwd(), 'config.json');
if (fsExt.existsSync(configJson)) {
configJson = fsExt.readFileSync(configJson);
configJson = JSON.parse(configJson);
proxyConfigMapping.main = configJson;
config.addConfig(configJson);
}
async.forEach(getProxyUrl('/config.json'), function(proxy, callback) {
Sources.loadUrl(proxy, function(body) {
var proxyConfig = body || '{}';
proxyConfig = JSON.parse(proxyConfig);
proxyConfigMapping[getHref(proxy)] = proxyConfig;
config.addConfig(proxyConfig);
callback();
});
}, function() {
config.bind('end', function() {
configCache = config.get();
cb();
});
});
};
function(direction_id, cb) {
if(!trip_ids[direction_id]) return cb();
async.forEach(
trip_ids[direction_id],
function(trip_id, cb) {
StopTime.find({
agency_key: agency_key,
trip_id: trip_id
},
null, {
sort: 'stop_sequence'
},
function(e, stopTimes) {
//compare to longest trip for given direction_id to see if trip length is longest for given direction
if(!longestTrip[direction_id]) longestTrip[direction_id] = [];
if(stopTimes.length && stopTimes.length > longestTrip[direction_id].length) {
longestTrip[direction_id] = stopTimes;
}
cb();
exports.getUsage = function(id, callback) {
var settings = config.middleware.rate_limiting, result = [];
async.forEach(settings.limits, function(rule, callback) {
async.waterfall([
calculateBucketKeyNames.bind(null, id, rule),
getCurrentUsage,
function getOverrides(keys, usage, bucketNameToValueMap, callback) {
getLimitOverrides(id, rule.path_regex, function(err, value) {
var limit = rule.limit;
if (err) {
callback(err);
return;
}
if (value) {
limit = value;
}