arbitrary-promise
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -63,2 +63,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -120,3 +122,5 @@ | ||
// Get all data previously called from pass funk | ||
_this2._state[stateKey].forEach(handler); | ||
_this2._state[stateKey].forEach(function (args) { | ||
return handler.apply(undefined, _toConsumableArray(args)); | ||
}); | ||
@@ -127,8 +131,12 @@ // return this for chaining | ||
this[pass] = function (data) { | ||
this[pass] = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
// Save data for future receive assignments to get | ||
_this2._state[stateKey].push(data); | ||
_this2._state[stateKey].push(args); | ||
// Call receive function with data | ||
_this2[handlerKey] && _this2[handlerKey](data); | ||
_this2[handlerKey] && _this2[handlerKey].apply(_this2, args); | ||
@@ -135,0 +143,0 @@ // return this for chaining |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.arbitraryPromise=e():t.arbitraryPromise=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var i=r[n]={exports:{},id:n,loaded:!1};return t[n].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var n=function(){function t(t,e){var r=[],n=!0,i=!1,a=void 0;try{for(var o,s=t[Symbol.iterator]();!(n=(o=s.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(t){i=!0,a=t}finally{try{!n&&s.return&&s.return()}finally{if(i)throw a}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),a=function(){function t(e){if(r(this,t),!this._validatePassReceivePairs(e))throw new Error("must pass in tuples of function names like [['handleData', 'onData'], ...]");this._createState(),e.forEach(this._processPassReceivePair.bind(this))}return i(t,[{key:"clear",value:function(){this._resetState()}},{key:"_createState",value:function(){this._state={}}},{key:"_resetState",value:function(){var t=this;Object.keys(this._state).forEach(function(e){t._state[e]=[]})}},{key:"_processPassReceivePair",value:function(t){var e=this,r=n(t,2),i=r[0],a=r[1],o="__state_"+i,s="__handler_"+a;this._state[o]=[],this[a]=function(t){return e[s]=t,e._state[o].forEach(t),e},this[i]=function(t){return e._state[o].push(t),e[s]&&e[s](t),e}}},{key:"_validatePassReceivePairs",value:function(t){var e=Array.isArray(t);if(!e)return!1;var r=t.length>=1;if(!r)return!1;var n=t.every(function(t){return 2===t.length});if(!n)return!1;var i=t.every(function(t){return"string"==typeof t[0]&&"string"==typeof t[1]});return!!i}}]),t}();t.exports=a}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.arbitraryPromise=e():t.arbitraryPromise=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:!1};return t[n].call(a.exports,a,a.exports,e),a.loaded=!0,a.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e){"use strict";function r(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var a=function(){function t(t,e){var r=[],n=!0,a=!1,i=void 0;try{for(var o,u=t[Symbol.iterator]();!(n=(o=u.next()).done)&&(r.push(o.value),!e||r.length!==e);n=!0);}catch(t){a=!0,i=t}finally{try{!n&&u.return&&u.return()}finally{if(a)throw i}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=function(){function t(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),o=function(){function t(e){if(n(this,t),!this._validatePassReceivePairs(e))throw new Error("must pass in tuples of function names like [['handleData', 'onData'], ...]");this._createState(),e.forEach(this._processPassReceivePair.bind(this))}return i(t,[{key:"clear",value:function(){this._resetState()}},{key:"_createState",value:function(){this._state={}}},{key:"_resetState",value:function(){var t=this;Object.keys(this._state).forEach(function(e){t._state[e]=[]})}},{key:"_processPassReceivePair",value:function(t){var e=this,n=a(t,2),i=n[0],o=n[1],u="__state_"+i,s="__handler_"+o;this._state[u]=[],this[o]=function(t){return e[s]=t,e._state[u].forEach(function(e){return t.apply(void 0,r(e))}),e},this[i]=function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e._state[u].push(r),e[s]&&e[s].apply(e,r),e}}},{key:"_validatePassReceivePairs",value:function(t){var e=Array.isArray(t);if(!e)return!1;var r=t.length>=1;if(!r)return!1;var n=t.every(function(t){return 2===t.length});if(!n)return!1;var a=t.every(function(t){return"string"==typeof t[0]&&"string"==typeof t[1]});return!!a}}]),t}();t.exports=o}])}); | ||
//# sourceMappingURL=arbitrary-promise.min.js.map |
@@ -7,2 +7,4 @@ 'use strict'; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -64,3 +66,5 @@ | ||
// Get all data previously called from pass funk | ||
_this2._state[stateKey].forEach(handler); | ||
_this2._state[stateKey].forEach(function (args) { | ||
return handler.apply(undefined, _toConsumableArray(args)); | ||
}); | ||
@@ -71,8 +75,12 @@ // return this for chaining | ||
this[pass] = function (data) { | ||
this[pass] = function () { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
// Save data for future receive assignments to get | ||
_this2._state[stateKey].push(data); | ||
_this2._state[stateKey].push(args); | ||
// Call receive function with data | ||
_this2[handlerKey] && _this2[handlerKey](data); | ||
_this2[handlerKey] && _this2[handlerKey].apply(_this2, args); | ||
@@ -79,0 +87,0 @@ // return this for chaining |
{ | ||
"name": "arbitrary-promise", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "ArbitraryPromise is a simple Promise library that allows you to make your own arbitrarily named resolve/then functions.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58544
268