Sha256: 1bde47da70afb34c535e9710b3fef4c866d6111d7ba9fa460d44cec5dd1d7242

Contents?: true

Size: 1.27 KB

Versions: 34

Compression:

Stored size: 1.27 KB

Contents

// This file should be ES5 compatible
/* eslint prefer-spread:0, no-var:0, prefer-reflect:0, no-magic-numbers:0 */
'use strict'

module.exports = (function () {
	// Import Events
	var events = require('events')

	// Export Domain
	var domain = {}
	domain.createDomain = domain.create = function () {
		var d = new events.EventEmitter()

		function emitError (e) {
			d.emit('error', e)
		}

		d.add = function (emitter) {
			emitter.on('error', emitError)
		}
		d.remove = function (emitter) {
			emitter.removeListener('error', emitError)
		}
		d.bind = function (fn) {
			return function () {
				var args = Array.prototype.slice.call(arguments)
				try {
					fn.apply(null, args)
				}
				catch (err) {
					emitError(err)
				}
			}
		}
		d.intercept = function (fn) {
			return function (err) {
				if ( err ) {
					emitError(err)
				}
				else {
					var args = Array.prototype.slice.call(arguments, 1)
					try {
						fn.apply(null, args)
					}
					catch (err) {
						emitError(err)
					}
				}
			}
		}
		d.run = function (fn) {
			try {
				fn()
			}
			catch (err) {
				emitError(err)
			}
			return this
		}
		d.dispose = function () {
			this.removeAllListeners()
			return this
		}
		d.enter = d.exit = function () {
			return this
		}
		return d
	}
	return domain
}).call(this)

Version data entries

34 entries across 33 versions & 11 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/domain-browser/source/index.js
disco_app-0.18.0 test/dummy/node_modules/domain-browser/source/index.js
disco_app-0.18.2 test/dummy/node_modules/domain-browser/source/index.js
disco_app-0.16.1 test/dummy/node_modules/domain-browser/source/index.js
disco_app-0.15.2 test/dummy/node_modules/domain-browser/source/index.js
disco_app-0.18.4 test/dummy/node_modules/domain-browser/source/index.js
disco_app-0.18.1 test/dummy/node_modules/domain-browser/source/index.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/domain-browser/source/index.js
disco_app-0.14.0 test/dummy/node_modules/domain-browser/source/index.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/domain-browser/source/index.js
tang-0.2.1 spec/tang_app/node_modules/domain-browser/source/index.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/domain-browser/source/index.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/domain-browser/source/index.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/domain-browser/source/index.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/domain-browser/source/index.js
tang-0.2.0 spec/tang_app/node_modules/domain-browser/source/index.js
tang-0.1.0 spec/tang_app/node_modules/domain-browser/source/index.js
tang-0.0.9 spec/tang_app/node_modules/domain-browser/source/index.js
enju_library-0.3.8 spec/dummy/node_modules/domain-browser/source/index.js
ilog-0.4.1 node_modules/domain-browser/source/index.js