eventproxy
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -185,6 +185,10 @@ /*global exports */ | ||
_all = function () { | ||
_all = function (event) { | ||
if (times < length) { | ||
return; | ||
} | ||
if (!flag[event]) { | ||
return; | ||
} | ||
var data = []; | ||
@@ -197,2 +201,3 @@ for (index = 0; index < length; index++) { | ||
} | ||
callback.apply(null, data); | ||
@@ -199,0 +204,0 @@ }; |
@@ -23,3 +23,3 @@ { | ||
"main" : "eventproxy.js", | ||
"version" : "0.1.1" | ||
"version" : "0.1.2" | ||
} |
这个世界上不存在所谓回调函数深度嵌套的问题。 —— Jackson Tian(http://weibo.com/shyvo) | ||
--- | ||
[![Build Status](https://secure.travis-ci.org/JacksonTian/eventproxy.png)](http://travis-ci.org/JacksonTian/eventproxy) | ||
--- | ||
@@ -4,0 +7,0 @@ |
@@ -146,4 +146,6 @@ /** | ||
assert.equal(counter, 2, 'counter should be incremented.'); | ||
ep.trigger('event3', "The event not in list"); | ||
assert.equal(counter, 2, 'counter should not be incremented.'); | ||
}, | ||
'after, n times': function() { | ||
@@ -171,3 +173,17 @@ var ep = EventProxy.create(); | ||
}, | ||
'after, 1 time': function() { | ||
var ep = EventProxy.create(); | ||
var counter = 0; | ||
ep.after('event', 1, function(data) { | ||
assert.deepEqual(data.length, 1); | ||
assert.deepEqual(data[0], "1 time"); | ||
counter += 1; | ||
}); | ||
ep.trigger('event', "1 time"); | ||
assert.deepEqual(counter, 1, 'counter should have only been incremented once.'); | ||
}, | ||
'after, 0 time': function () { | ||
@@ -174,0 +190,0 @@ var obj = new EventProxy(); |
@@ -106,2 +106,4 @@ test("EventProxy - bind/trigger", function() { | ||
equals(counter, 2, 'counter should be incremented.'); | ||
obj.trigger('event3', 'This event not in list'); | ||
equals(counter, 2, 'counter should not be incremented.'); | ||
}); | ||
@@ -130,2 +132,16 @@ | ||
test("EventProxy - after, 1 time", function() { | ||
var obj = EventProxy.create(); | ||
var counter = 0; | ||
obj.after('event', 1, function(data) { | ||
equals(data.length, 1, "The data length should be 1."); | ||
equals(data[0], "1 time", "The item should be 1 time."); | ||
counter += 1; | ||
}); | ||
obj.trigger('event', "1 time"); | ||
equals(counter, 1, 'counter should have only been incremented once.'); | ||
}) | ||
test("EventProxy - after, 0 time", function () { | ||
@@ -132,0 +148,0 @@ var obj = new EventProxy(); |
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
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
210465
15
700
131
1