How to use the taskgroup.TaskGroup.create function in taskgroup

To help you get started, we’ve selected a few taskgroup examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bevry-archive / feedr / source / index.js View on Github external
function writeFeed(response, data, writeFeedComplete) {
			// Log
			me.log('debug', `Feedr === writing [${feed.url}] to [${feed.path}]`)

			// Prepare
			const writeTasks = TaskGroup.create({ concurrency: 0 }).done(function(
				err
			) {
				if (err) {
					// Log
					me.log(
						'warn',
						`Feedr === writing [${feed.url}] to [${feed.path}], write failed`,
						err.stack
					)

					// Exit
					writeFeedComplete(err)
					return
				}

				// Log
github bevry-archive / feedr / source / index.js View on Github external
function viaCache(viaCacheComplete) {
			// Log
			me.log('debug', `Feedr === remembering [${feed.url}] from cache`)

			// Prepare
			let meta = null
			let data = null
			const readTasks = TaskGroup.create().done(function(err) {
				viaCacheComplete(err, data, meta && meta.headers)
			})

			readTasks.addTask('read the meta data in a cache somewhere', function(
				viaCacheTaskComplete
			) {
				readMetaFile(feed.metaPath, function(err, result) {
					if (err || !result) {
						viaCacheTaskComplete(err)
						return
					}
					meta = result
					viaCacheTaskComplete()
				})
			})
github bevry-archive / feedr / source / index.js View on Github external
} else if (typeChecker.isArray(arg)) {
				feeds = arg
			} else if (typeChecker.isPlainObject(arg)) {
				if (index === 0) {
					feeds = arg
				} else {
					extendr.extend(defaultfeed, arg)
				}
			}
		})

		// Extract
		const results = {}

		// Tasks
		const tasks = TaskGroup.create({
			concurrency: 0,
			abortOnError: false
		}).done(function() {
			let message = 'Feedr finished fetching'
			let err = null

			if (failures.length !== 0) {
				message +=
					`with ${failures.length} failures:\n` +
					failures
						.map(function(i) {
							return i.message
						})
						.join('\n')
				err = new Error(message)
				me.log('warn', err)

taskgroup

Group together synchronous and asynchronous tasks and execute them with support for concurrency, naming, and nesting.

Artistic-2.0
Latest version published 10 months ago

Package Health Score

61 / 100
Full package analysis