How to use unbounded - 3 common examples

To help you get started, we’ve selected a few unbounded 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 / taskgroup / source / task.js View on Github external
const taskArgs = (this.config.args || []).slice()
		let taskDomain = this.state.taskDomain
		const exitMethod = unbounded.binder.call(this.itemCompletionCallback, this)
		let method = this.config.method

		// Check that we have a method to fire
		if (!method) {
			const error = new Error(
				`The task [${this.names}] failed to run as no method was defined for it.`
			)
			this.emit('error', error)
			return this
		}

		// Bind method
		method = unbounded.binder.call(method, this)

		// Handle domains
		if (domain) {
			// Prepare the task domain if we want to and if it doesn't already exist
			if (!taskDomain && this.config.domain !== false) {
				this.state.taskDomain = taskDomain = domain.create()
				taskDomain.on('error', exitMethod)
			}
		} else if (this.config.domain === true) {
			const error = new Error(
				`The task [${this.names}] failed to run as it requested to use domains but domains are not available.`
			)
			this.emit('error', error)
			return this
		}
github bevry / taskgroup / source / task.js View on Github external
fire() {
		// Prepare
		const taskArgs = (this.config.args || []).slice()
		let taskDomain = this.state.taskDomain
		const exitMethod = unbounded.binder.call(this.itemCompletionCallback, this)
		let method = this.config.method

		// Check that we have a method to fire
		if (!method) {
			const error = new Error(
				`The task [${this.names}] failed to run as no method was defined for it.`
			)
			this.emit('error', error)
			return this
		}

		// Bind method
		method = unbounded.binder.call(method, this)

		// Handle domains
		if (domain) {
github bevry / taskgroup / source / taskgroup.js View on Github external
addMethod(method, opts = {}) {
		method = unbounded.binder.call(method, this) // run the taskgroup method on the group, rather than itself
		method.isTaskGroupMethod = true
		if (!opts.name) opts.name = 'taskgroup method for ' + this.name
		if (!opts.args)
			opts.args = [this.addTaskGroup.bind(this), this.addTask.bind(this)]
		if (opts.storeResult == null) opts.storeResult = false // by default, hide result for methods
		this.addTask(method, opts)
		return this
	}

unbounded

Function.prototype.bind replacement that provides an `unbounded` hidden property on the returned bounded function, that contains the original unbounded function

Artistic-2.0
Latest version published 11 months ago

Package Health Score

68 / 100
Full package analysis

Popular unbounded functions