Skip to content

Commit 763f35e

Browse files
authored
Revert "events.next() is placed in the wrong scope (#116)" (#117)
This reverts commit ec60421.
1 parent ec60421 commit 763f35e

File tree

2 files changed

+10
-49
lines changed

2 files changed

+10
-49
lines changed

lib/eventstore.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,16 @@ _.extend(Eventstore.prototype, {
123123
getEvents: function (query, skip, limit, callback) {
124124
var self = this;
125125

126+
function nextFn(callback) {
127+
if (limit < 0) {
128+
var resEvts = [];
129+
resEvts.next = nextFn;
130+
return process.nextTick(function () { callback(null, resEvts) });
131+
}
132+
skip += limit;
133+
_getEvents(query, skip, limit, callback);
134+
}
135+
126136
function _getEvents(query, skip, limit, callback) {
127137
if (typeof query === 'function') {
128138
callback = query;
@@ -151,16 +161,6 @@ _.extend(Eventstore.prototype, {
151161
query = { aggregateId: query };
152162
}
153163

154-
function nextFn(callback) {
155-
if (limit < 0) {
156-
var resEvts = [];
157-
resEvts.next = nextFn;
158-
return process.nextTick(function () { callback(null, resEvts) });
159-
}
160-
skip += limit;
161-
_getEvents(query, skip, limit, callback);
162-
}
163-
164164
self.store.getEvents(query, skip, limit, function (err, evts) {
165165
if (err) return callback(err);
166166
evts.next = nextFn;

test/eventstoreTest.js

-39
Original file line numberDiff line numberDiff line change
@@ -1170,45 +1170,6 @@ describe('eventstore', function () {
11701170

11711171
});
11721172

1173-
describe('requesting all existing events, without query argument and using next function', function () {
1174-
1175-
describe('and committing some new events', function () {
1176-
1177-
it('it should work as expected', function (done) {
1178-
1179-
es.getEvents(0, 3, function (err, evts) {
1180-
expect(err).not.to.be.ok();
1181-
1182-
expect(evts.length).to.eql(3);
1183-
1184-
expect(evts.next).to.be.a('function');
1185-
1186-
evts.next(function (err, nextEvts) {
1187-
expect(err).not.to.be.ok();
1188-
1189-
expect(nextEvts.length).to.eql(3);
1190-
1191-
expect(nextEvts.next).to.be.a('function');
1192-
1193-
nextEvts.next(function (err, nextNextEvts) {
1194-
expect(err).not.to.be.ok();
1195-
1196-
expect(nextNextEvts.length).to.eql(2);
1197-
1198-
expect(nextNextEvts.next).to.be.a('function');
1199-
1200-
done();
1201-
});
1202-
});
1203-
1204-
});
1205-
1206-
});
1207-
1208-
});
1209-
1210-
});
1211-
12121173
describe('requesting existing events since a date and using next function', function () {
12131174

12141175
describe('and committing some new events', function () {

0 commit comments

Comments
 (0)