-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.js
More file actions
30 lines (27 loc) · 785 Bytes
/
Copy pathexample.js
File metadata and controls
30 lines (27 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'use strict';
var through = require('through2');
var changes = require('./');
// get the changes from the npm registry
var options = {
db: 'https://skimdb.npmjs.com/registry',
// since is the seq number to start after
since: 1283832,
// only return 10 changes
// this will cause the stream to end once 10 changes have passed through
limit: 10
};
changes(options)
.on('current', function(seq) {
console.log('caught up to the current update', seq);
})
.on('error', console.error)
.pipe(through.obj(function(file, enc, next) {
console.log(file.seq, file.id);
next(null, file);
}))
.on('error', console.error)
// pull the data through so the stream doesn't stop
.on('data', function() {})
.on('end', function() {
console.log('done');
});