本文整理匯總了TypeScript中async.eachSeries函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript eachSeries函數的具體用法?TypeScript eachSeries怎麽用?TypeScript eachSeries使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了eachSeries函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: callback
utils.kongGetAllApis(function (err, rawApiList) {
if (err)
return callback(err);
let apiList: KongApiConfigCollection = {
apis: []
};
// Add an "api" property for the configuration, makes it easier
// to compare the portal and Kong configurations.
for (let i = 0; i < rawApiList.data.length; ++i) {
apiList.apis.push({
api: rawApiList.data[i]
});
}
// Fire off this sequentially, not in parallel (renders 500's sometimes)
async.eachSeries(apiList.apis, function (apiDef: KongApiConfig, callback) {
utils.kongGetApiPlugins(apiDef.api.id, function (err, apiConfig) {
if (err)
return callback(err);
apiDef.plugins = apiConfig.data;
return callback(null);
});
}, function (err) {
if (err)
return callback(err);
// Plugins which are referring to consumers are not global, and must not be taken
// into account when comparing.
apiList = removeKongConsumerPlugins(apiList);
return callback(null, apiList);
});
});
示例2: function
addKongApis: function (addList: AddApiItem[], done): void {
// Bail out early if list empty
if (addList.length === 0) {
setTimeout(done, 0);
return;
}
debug('addKongApis()');
// Each item in addList contains:
// - portalApi: The portal's API definition, including plugins
async.eachSeries(addList, function (addItem: AddApiItem, callback) {
info(`Creating new API in Kong: ${addItem.portalApi.id}`);
utils.kongPostApi(addItem.portalApi.config.api, function (err, apiResponse) {
if (err)
return done(err);
const kongApi = { api: apiResponse };
debug(kongApi);
const addList = [];
for (let i = 0; i < addItem.portalApi.config.plugins.length; ++i) {
addList.push({
portalApi: addItem,
portalPlugin: addItem.portalApi.config.plugins[i],
kongApi: kongApi,
});
}
kong.addKongPlugins(addList, callback);
});
}, function (err) {
if (err)
return done(err);
done(null);
});
},
示例3: mergeAverageDownloadsPerDay
mergeAverageDownloadsPerDay(packages, (error, packages) => {
if (error) return callback(error);
logger.debug('updating with %d packages (%s)', packages.length, updates_only ? 'updates only' : 'all packages');
var batches = _.chunk(packages, 500);
async.eachSeries(batches, insertPackages, callback);
});
示例4: function
wicked.getWebhookEvents('kong-adapter', function (err, pendingEvents) {
if (err) {
error('COULD NOT RETRIEVE WEBHOOKS')
return callback(err);
}
const duration = (new Date().getTime() - now);
debug(`processPendingWebhooks: Retrieved ${pendingEvents.length} events in ${duration}ms`);
const onlyDelete = false;
if (pendingEvents.length === 0)
return callback(null, false);
async.eachSeries(pendingEvents, (webhookData: WickedEvent, callback) => {
const now = new Date().getTime();
dispatchWebhookAction(webhookData, onlyDelete, function (err) {
const duration = (new Date().getTime() - now);
debug(`processPendingWebhooks: Processed ${webhookData.action} ${webhookData.entity} event in ${duration}ms`);
if (err)
return callback(err);
return callback(null);
});
}, function (err) {
if (err) {
error('An error occurred during dispatching events.');
error(err);
return callback(err);
}
return callback(null, true);
});
});
示例5: return
return (dispatch, getState) => {
var globalState: GlobalStoreDataType = getState();
var repos = globalState.git.get("repos").toArray();
const fetchCommits = (item: Repo, callback: Function) => {
const onSuccess = () => {
// callback();
}
dispatch(getCommits(item, onSuccess))
}
const onFinish = (errorCode: Error) => {
alert("success");
}
async.eachSeries(repos, fetchCommits, onFinish)
}
示例6: windows_find_java_home
/**
* Find Java on Windows by checking registry keys.
*/
function windows_find_java_home(grunt: IGrunt, cb: (success: boolean, java_home?: string, append_exe?: boolean) => void): void {
// Windows: JDK path is in either of the following registry keys:
// - HKLM\Software\JavaSoft\Java Development Kit\1.[version] [JDK arch == OS arch]
// - HKLM\Software\Wow6432Node\JavaSoft\Java Development Kit\1.[version] [32-bit JDK Arch, 64-bit OS arch]
// Check both for Java 6, 7, and 8.
var keys_to_check: string[] = [
'HKLM\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6',
'HKLM\\SOFTWARE\\Wow6432Node\\JavaSoft\\Java Development Kit\\1.6',
'HKLM\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7',
'HKLM\\SOFTWARE\\Wow6432Node\\JavaSoft\\Java Development Kit\\1.7',
'HKLM\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8',
'HKLM\\SOFTWARE\\Wow6432Node\\JavaSoft\\Java Development Kit\\1.8'
];
async.eachSeries(keys_to_check, (key: string, iterator_cb: (java_home?: string) => void) => {
get_registry_key(key, (err: Error, values?: { [valName: string]: string }) => {
if (err || !values['JavaHome']) {
iterator_cb();
} else {
iterator_cb(values['JavaHome']);
}
});
}, (java_home?: string): void => {
if (java_home) {
cb(true, java_home, true);
} else {
cb(false);
}
});
}
示例7: process
process(done: () => void) {
// preprocess
for (let name in this.sql.statements) {
this.sql.statements[name].name = name;
}
for (let name in this.sql.tokens) {
this.sql.tokens[name].name = name;
}
for (let name in this.sql.dialects) {
this.sql.dialects[name].name = name;
}
var csg = new cs(this);
var javag = new java(this);
var nodeg = new node(this);
async.eachSeries([csg, javag, nodeg],
(generator, cb) => {
generator.generate(() => {
cb(null);
});
}, () => {
console.log("done");
process.exit(0);
});
}
示例8: init
function init() {
if (!fs.existsSync(rootPath)) {
return;
}
console.log('init------start ');
let fileList: string[] = fs.readdirSync(rootPath);
docsLoadingState = false;
asyncjs.eachSeries(fileList, (file, callback) => {
if (!fs.statSync(rootPath + file).isDirectory()) {
return callback(null);
}
fs.readFile(rootPath + file + '/db.json', { encoding: 'utf-8' }, (err, data) => {
if (err) {
console.log('load file ' + file + 'error:' + err);
} else {
docsDB[file] = JSON.parse(data);
}
callback(null);
});
}, err => {
if (!err) {
docsLoadingState = true;
}
console.log('init------end ');
});
}
示例9: getImagesInFolder
function getImagesInFolder(dir: string, imgInFolderCb: Function): void {
let files = fs.readdirSync(dir);
let images: number[][] = [];
async.eachSeries(files,
function(file: string, asyncCallback: Function) {
jimp.read(dir + file, function (err: any, img: any) {
if (err) throw err;
images.push(img.bitmap.data);
process.stdout.write('.');
// img.scan(0, 0, img.bitmap.width, img.bitmap.height, function (x: number, y: number, idx: number) {
// // x, y is the position of this pixel on the image
// // idx is the position start position of this rgba tuple in the bitmap Buffer
// // this is the image
//
// imgPixels.push(this.bitmap.data[idx]); // Red
// imgPixels.push(this.bitmap.data[idx + 1]); // Green
// imgPixels.push(this.bitmap.data[idx + 2]); // Blue
//
// // rgba values run from 0 - 255
// // e.g. this.bitmap.data[idx] = 0; // removes red from this pixel
// });
// images[index] = imgPixels;
asyncCallback();
});
},
function(err: any){
if (err) throw err;
imgInFolderCb(null, images);
}
);
}
示例10: migrateTo3
function migrateTo3(server: ProjectServer, callback: (err: Error) => any) {
const assetsPath = path.join(server.projectPath, "assets");
async.eachSeries(Object.keys(server.data.entries.byId), (nodeId, cb) => {
const node = server.data.entries.byId[nodeId];
const storagePath = server.data.entries.getStoragePathFromId(nodeId);
if (node.type == null) cb();
else {
const index = storagePath.lastIndexOf("/");
let parentStoragePath = storagePath;
const oldStoragePath = path.join(assetsPath, `${nodeId}-${server.data.entries.getPathFromId(nodeId).replace(new RegExp("/", "g"), "__")}`);
if (index !== -1) {
parentStoragePath = storagePath.slice(0, index);
mkdirp(path.join(assetsPath, parentStoragePath), (err) => {
if (err != null && err.code !== "EEXIST") { cb(err); return; }
fs.rename(oldStoragePath, path.join(assetsPath, storagePath), cb);
});
} else {
fs.rename(oldStoragePath, path.join(assetsPath, storagePath), cb);
}
}
}, callback);
}
示例11: callback
utils.kongGetLegacyApis(function (err, legacyApis) {
if (err)
return callback(err);
async.eachSeries(legacyApis.data, (legacyApi, callback) => {
info(`Deleting Legacy Kong API ${legacyApi.name}.`);
utils.kongDeleteLegacyApi(legacyApi.name, callback);
}, callback);
});
示例12: addKongConsumerPlugin
function addKongConsumerPlugin(consumerId: string, pluginName: string, pluginDataList: ConsumerPlugin[], done) {
debug('addKongConsumerPlugin()');
async.eachSeries(pluginDataList, function (pluginData: ConsumerPlugin, callback) {
info(`Adding consumer plugin ${pluginName} for consumer ${consumerId}`);
utils.kongPostConsumerPlugin(consumerId, pluginName, pluginData, callback);
}, function (err) {
if (err)
return done(err);
done(null);
});
}
示例13: return
return (req: Request, res: Response, next: NextFunction) => {
if (Array.isArray(fun) === true) {
return eachSeries(fun as RequestHandler[], (f, cb) => {
Promise.resolve(f(req, res, cb))
.catch(err => next(err))
}, next)
}
return Promise.resolve((fun as RequestHandler)(req, res, next))
.catch(err => next(err))
}
示例14: deleteKongConsumerPlugin
function deleteKongConsumerPlugin(consumerId, pluginName, pluginDataList, done) {
debug('deleteKongConsumerPlugin()');
async.eachSeries(pluginDataList, function (pluginData, callback) {
info(`Deleting consumer plugin ${pluginName} for consumer ${consumerId}`);
utils.kongDeleteConsumerPlugin(consumerId, pluginName, pluginData.id, callback);
}, function (err) {
if (err)
return done(err);
done(null);
});
}
示例15: symlink_java_home
function symlink_java_home(grunt: IGrunt, cb: (err?: any) => void): void {
var java_home: string = 'vendor/java_home',
JH: string,
links;
if (fs.existsSync(java_home)) {
return cb();
}
grunt.config.requires('build.scratch_dir');
JH = path.resolve(grunt.config('build.scratch_dir'), 'usr', 'lib', 'jvm', 'java-6-openjdk-i386', 'jre'),
// a number of .properties files are symlinks to /etc; copy the targets over
// so we do not need to depend on /etc's existence
links = find_symlinks(JH);
async.eachSeries(links, function(link, cb2){
try {
var dest = fs.readlinkSync(link);
if (dest.match(/^\/etc/)) {
ncp(path.join(grunt.config('build.scratch_dir'), dest), link, function(err?: any) {
if (err) {
// Some /etc symlinks are just broken. Hopefully not a big deal.
grunt.log.writeln('warning: broken symlink: ' + dest);
}
cb2(null);
});
} else {
var p = path.resolve(path.join(path.dirname(link), dest));
// copy in anything that links out of the JH dir
if (!p.match(/java-6-openjdk-i386/)) {
// XXX: this fails if two symlinks reference the same file
if (fs.statSync(p).isDirectory()) {
fs.unlinkSync(link);
}
ncp(p, link, function(err?: any) {
if (err) {
grunt.log.writeln('warning: broken symlink: ' + p);
}
cb2(null);
});
} else {
// Nothing to do.
cb2(null);
}
}
} catch (e) {
grunt.log.writeln('warning: broken symlink: ' + link);
cb2(null);
}
}, function(err){
ncp(JH, java_home, function(err2?: any) {
err2 = err2 ? err2 : err;
cb(err2);
});
});
}