Skip to content

Commit fab164c

Browse files
committed
Removed collectFirst. We can pass a function to collect to determine the position of the collector in queue. Filter must be assigned once collector is created.
1 parent 3df5ea4 commit fab164c

File tree

11 files changed

+27
-21
lines changed

11 files changed

+27
-21
lines changed

.npmignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ npm-debug.log*
1515
.grunt
1616

1717
# Files
18-
test*.*
18+
src/
19+
test/
20+
examples/
21+
test*.*

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dop",
3-
"version": "0.22.4",
3+
"version": "0.22.5",
44
"main": "./dist/dop.nodejs.js",
55
"browser": "./dist/dop.js",
66
"unpkg": "./dist/dop.min.js",

src/api/collect.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11

2-
dop.collect = function(filter) {
3-
dop.util.invariant(arguments.length===0 || (arguments.length>0 && isFunction(filter)), 'dop.collect only accept one argument as function');
4-
return dop.core.createCollector(dop.data.collectors, dop.data.collectors.length, filter);
2+
dop.collect = function(indexFunction) {
3+
dop.util.invariant(arguments.length==0 || (arguments.length==1 && isFunction(indexFunction)), 'dop.collect only accept one argument as function');
4+
var index = indexFunction ? indexFunction(dop.data.collectors) : dop.data.collectors.length;
5+
return dop.core.createCollector(dop.data.collectors, index);
56
};

src/api/collectFirst.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/core/constructors/collector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
dop.core.collector = function(queue, index) {
2+
dop.core.collector = function Collector(queue, index) {
33
this.active = true;
44
this.mutations = [];
55
this.queue = queue;

src/core/constructors/listener.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
dop.core.listener = function(args) {
2+
dop.core.listener = function Listener(args) {
33
// Inherit emitter
44
dop.util.merge(this, new dop.util.emitter);
55
args.unshift(dop, this);

src/core/constructors/node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
dop.core.node = function() {
2+
dop.core.node = function Node() {
33
// Inherit emitter
44
dop.util.merge(this, new dop.util.emitter); //https://jsperf.com/inheritance-call-vs-object-assign
55
this.connected = false;

src/core/constructors/observer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
dop.core.observer = function(callback, id) {
2+
dop.core.observer = function Observer(callback, id) {
33
this.callback = callback;
44
this.id = id;
55
this.observers = {}; // need it for destroy()

src/core/constructors/snapshot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
dop.core.snapshot = function (mutations) {
2+
dop.core.snapshot = function Snapshot(mutations) {
33
this.mutations = mutations;
44
this.forward = true;
55
};

src/core/objects/createCollector.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

2-
dop.core.createCollector = function(queue, index, filter) {
2+
dop.core.createCollector = function(queue, index) {
33
var collector = new dop.core.collector(queue, index);
4-
collector.filter = filter;
54
return collector;
65
};

0 commit comments

Comments
 (0)