Comparing version 0.0.7 to 0.0.8
@@ -5,3 +5,3 @@ { | ||
"description": "Observable functions", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"homepage": "https://github.com/ifrost/off", | ||
@@ -8,0 +8,0 @@ "authors": [ |
@@ -1,1 +0,1 @@ | ||
!function(n,r){"function"==typeof define&&define.amd?define(function(){return n.off=r()}):"object"==typeof module&&module.exports?module.exports=n.off=r():n.off=r()}(this,function(){var n=function(n,r){var t=[],e=[];n=n||function(){};var o=function(){var n,u,f,i=r||this;return n=Array.prototype.slice.call(arguments,0),(u=e.some(function(r){return r.apply(this,n)}))?void 0:(f=o.func.apply(i,n),o.lock?o.lock=!1:t.forEach(function(n){f instanceof Function&&f._off?f.add(n):n.call(i,f)}),f)};return o.before=function(n,r){return r=r||{},(-1===e.indexOf(n)||r.force_add)&&e.push(n),o},o.add=function(n,r){return r=r||{},(-1===t.indexOf(n)||r.force_add)&&t.push(n),o},o.override=function(n){var r=o.func;o.func=function(){var t=Array.prototype.slice.call(arguments,0);return t.unshift(r.bind(this)),n.apply(this,t)}},o.remove=function(n){var r=t.indexOf(n);-1!==r&&t.splice(r,1)},o._off=!0,o.func=n,o};return n.signal=function(){return n(function(n){return n})},n.property=function(r,t){var e,o,u=r,f={};return t=t||function(n,r){return r()===n&&(r.property.lock=!0),r(n)},e=n(function(n,r){return 0===arguments.length&&r!==f?(e.lock=!0,u):t(n,o)}),e.bind=function(n){e.add(n),void 0!==e()&&n(e())},e.reset=function(){return e(f)},o=function(n){return arguments.length&&(u=n),u},o.property=e,e.property=!0,e},n.async=function(r,t){var e=null;return n(function(){var o;t&&e&&(e.lock=!0),e=o=n(function(n){return n},this);var u=Array.prototype.slice.call(arguments,0).concat(o);return r.apply(this,u),o})},n.deferred=function(r,t){var e,o,u,f=!1,i=null,c=n.signal();return o=n(function(){return i=Array.prototype.slice.call(arguments,0),e=c,f?c:(f=!0,t(function(){u=r.apply(this,i),f=!1,c(u)}),c)})},n.decorate=function(r){for(var t in r)"function"!=typeof r[t]||r[t]._off||(r[t]=n(r[t]));return r},n}); | ||
!function(n,r){"function"==typeof define&&define.amd?define(function(){return n.off=r()}):"object"==typeof module&&module.exports?module.exports=n.off=r():n.off=r()}(this,function(){var n=function(n,r){var t=[],e=[];n=n||function(){};var o=function(){var n,u,f,i=r||this;return n=Array.prototype.slice.call(arguments,0),(u=e.some(function(r){return r.apply(this,n)}))?void 0:(f=o.func.apply(i,n),o.lock?o.lock=!1:t.forEach(function(r){f instanceof Function&&f._off?f.add(r):r.apply(i,[f,n])}),f)};return o.before=function(n,r){return r=r||{},(-1===e.indexOf(n)||r.force_add)&&e.push(n),o},o.add=function(n,r){return r=r||{},(-1===t.indexOf(n)||r.force_add)&&t.push(n),o},o.override=function(n){var r=o.func;o.func=function(){var t=Array.prototype.slice.call(arguments,0);return t.unshift(r.bind(this)),n.apply(this,t)}},o.remove=function(n){var r=t.indexOf(n);-1!==r&&t.splice(r,1)},o._off=!0,o.func=n,o};return n.signal=function(){return n(function(n){return n})},n.property=function(r,t){var e,o,u=r,f={};return t=t||function(n,r){return r()===n&&(r.property.lock=!0),r(n)},e=n(function(n,r){return 0===arguments.length&&r!==f?(e.lock=!0,u):t(n,o)}),e.bind=function(n){e.add(n),void 0!==e()&&n(e())},e.reset=function(){return e(f)},o=function(n){return arguments.length&&(u=n),u},o.property=e,e.property=!0,e},n.async=function(r,t){var e=null;return n(function(){var o;t&&e&&(e.lock=!0),e=o=n(function(n){return n},this);var u=Array.prototype.slice.call(arguments,0).concat(o);return r.apply(this,u),o})},n.deferred=function(r,t){var e,o,u,f=!1,i=null,c=n.signal();return o=n(function(){return i=Array.prototype.slice.call(arguments,0),e=c,f?c:(f=!0,t(function(){u=r.apply(this,i),f=!1,c(u)}),c)})},n.decorate=function(r){for(var t in r)"function"!=typeof r[t]||r[t]._off||(r[t]=n(r[t]));return r},n}); |
@@ -41,3 +41,3 @@ (function (root, factory) { | ||
} else { | ||
handler.call(self, result); | ||
handler.apply(self, [result, args]); | ||
} | ||
@@ -44,0 +44,0 @@ }); |
{ | ||
"name": "off", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Observable functions", | ||
@@ -5,0 +5,0 @@ "main": "off.js", |
@@ -248,2 +248,13 @@ describe('off', function () { | ||
it('should pass result and args to handlers', function() { | ||
var method = off(function(a) { | ||
return a + 1; | ||
}); | ||
method.add(handler); | ||
method(1); | ||
expect(handler).toHaveBeenCalledWith(2, [1]); | ||
}); | ||
describe('signal', function () { | ||
@@ -262,3 +273,3 @@ | ||
expect(handler).toHaveBeenCalledWith('test'); | ||
expect(handler).toHaveBeenCalledWith('test', jasmine.any(Object)); | ||
@@ -265,0 +276,0 @@ }); |
Sorry, the diff of this file is not supported yet
36011
463