From 7153341c414f68352f753f335986cb84a87358c4 Mon Sep 17 00:00:00 2001 From: danielo Date: Fri, 25 Nov 2016 12:03:45 +0000 Subject: [PATCH] update emitr library to 0.0.9 --- .../sdk/libs/javascript/emitr/dist/emitr.js | 18 ++++++++++++------ .../sdk/libs/javascript/emitr/package.json | 17 +++++++++++------ .../sdk/libs/javascript/emitr/src/Emitter.js | 18 ++++++++++++------ 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/brjs-sdk/sdk/libs/javascript/emitr/dist/emitr.js b/brjs-sdk/sdk/libs/javascript/emitr/dist/emitr.js index 9d2b859d4..689b54172 100644 --- a/brjs-sdk/sdk/libs/javascript/emitr/dist/emitr.js +++ b/brjs-sdk/sdk/libs/javascript/emitr/dist/emitr.js @@ -10,16 +10,20 @@ var MultiMap = require('./MultiMap'); /////////////////////////////////////////////////////////////////////////// var ONCE_FUNCTION_MARKER = {}; -function notify(listeners, args) { +function notify(listeners, suppressErrors, args) { if (listeners.length === 0) { return false; } // take a copy in case one of the callbacks modifies the listeners array. listeners = listeners.slice(); for (var i = 0, len = listeners.length; i < len; ++i) { var listener = listeners[i]; - try { + if (suppressErrors) { + try { + listener.callback.apply(listener.context, args); + } catch (e) { + // Swallowing the errors will make this for-loop resilient + } + } else { listener.callback.apply(listener.context, args); - } catch(e) { - // do nothing } } return true; @@ -51,6 +55,8 @@ function Emitter() { this._emitterMetaEventsOn = false; } +Emitter.suppressErrors = true; + Emitter.prototype = { /** * Registers a listener for an event. @@ -204,7 +210,7 @@ Emitter.prototype = { args = slice.call(arguments, 1); if (this._emitterListeners.hasAny(event)) { anyListeners = true; - notify(this._emitterListeners.getValues(event), args); + notify(this._emitterListeners.getValues(event), Emitter.suppressErrors, args); } // navigate up the prototype chain emitting against the constructors. @@ -213,7 +219,7 @@ Emitter.prototype = { while (proto !== null && proto !== last) { if (this._emitterListeners.hasAny(proto.constructor)) { anyListeners = true; - notify(this._emitterListeners.getValues(proto.constructor), arguments); + notify(this._emitterListeners.getValues(proto.constructor), Emitter.suppressErrors, arguments); } last = proto; proto = Object.getPrototypeOf(proto); diff --git a/brjs-sdk/sdk/libs/javascript/emitr/package.json b/brjs-sdk/sdk/libs/javascript/emitr/package.json index 0d972e086..75dc487d7 100644 --- a/brjs-sdk/sdk/libs/javascript/emitr/package.json +++ b/brjs-sdk/sdk/libs/javascript/emitr/package.json @@ -1,6 +1,6 @@ { "name": "emitr", - "version": "0.0.8", + "version": "0.0.9", "description": "An node/browser event emitter that supports dispatching based on types.", "homepage": "http://BladeRunnerJS.github.io/emitr", "license": "MIT", @@ -10,19 +10,22 @@ }, "main": "./src/index.js", "scripts": { - "prepublish": "browserify src/index.js -s emitr -o dist/emitr.js", - "test": "npm run test:lint && npm run test:node && npm run test:browser && npm run test:saucelabs", - "test:lint": "eslint src test", + "prepublish": "mkdirp dist && browserify src/index.js -s emitr -o dist/emitr.js", + "postpublish": "publish-release --assets dist/emitr.js --notes 'Add release notes here.'", + "pretest": "npm run pretest:lint", + "pretest:lint": "eslint src test", + "test": "npm run test:node && npm run test:browser && npm run test:saucelabs", "test:node": "mocha test", "test:node:debug": "mocha test -w", "test:browser": "karma start", "test:browser:debug": "karma start karma-debug.conf.js", - "test:saucelabs": "karma start karma-saucelabs.conf.js" + "test:saucelabs": "envcheck SAUCE_ACCESS_KEY && karma start karma-saucelabs.conf.js" }, "devDependencies": { "browserify": "^11.0.0", "chai": "^3.2.0", "core-js": "^1.0.1", + "env-check": "^0.0.1", "eslint": "^0.24.1", "expectations": "^0.5.1", "karma": "^0.13.6", @@ -32,6 +35,8 @@ "karma-firefox-launcher": "^0.1.6", "karma-mocha": "^0.2.0", "karma-sauce-launcher": "^0.2.14", - "mocha": "^2.2.5" + "mkdirp": "^0.5.1", + "mocha": "^2.2.5", + "publish-release": "^1.0.2" } } diff --git a/brjs-sdk/sdk/libs/javascript/emitr/src/Emitter.js b/brjs-sdk/sdk/libs/javascript/emitr/src/Emitter.js index d9c421e19..a70f175b9 100644 --- a/brjs-sdk/sdk/libs/javascript/emitr/src/Emitter.js +++ b/brjs-sdk/sdk/libs/javascript/emitr/src/Emitter.js @@ -9,16 +9,20 @@ var MultiMap = require('./MultiMap'); /////////////////////////////////////////////////////////////////////////// var ONCE_FUNCTION_MARKER = {}; -function notify(listeners, args) { +function notify(listeners, suppressErrors, args) { if (listeners.length === 0) { return false; } // take a copy in case one of the callbacks modifies the listeners array. listeners = listeners.slice(); for (var i = 0, len = listeners.length; i < len; ++i) { var listener = listeners[i]; - try { + if (suppressErrors) { + try { + listener.callback.apply(listener.context, args); + } catch (e) { + // Swallowing the errors will make this for-loop resilient + } + } else { listener.callback.apply(listener.context, args); - } catch(e) { - // do nothing } } return true; @@ -50,6 +54,8 @@ function Emitter() { this._emitterMetaEventsOn = false; } +Emitter.suppressErrors = true; + Emitter.prototype = { /** * Registers a listener for an event. @@ -203,7 +209,7 @@ Emitter.prototype = { args = slice.call(arguments, 1); if (this._emitterListeners.hasAny(event)) { anyListeners = true; - notify(this._emitterListeners.getValues(event), args); + notify(this._emitterListeners.getValues(event), Emitter.suppressErrors, args); } // navigate up the prototype chain emitting against the constructors. @@ -212,7 +218,7 @@ Emitter.prototype = { while (proto !== null && proto !== last) { if (this._emitterListeners.hasAny(proto.constructor)) { anyListeners = true; - notify(this._emitterListeners.getValues(proto.constructor), arguments); + notify(this._emitterListeners.getValues(proto.constructor), Emitter.suppressErrors, arguments); } last = proto; proto = Object.getPrototypeOf(proto);