UNPKG

811 BJavaScriptView Raw
1#!/usr/bin/env node
2
3var base = require('./base.js');
4
5// base() creates a leveldb and a level-tree-index with some test data
6
7base(function(err, db, tree, cb) {
8 if(err) return cb(err);
9
10 var s = tree.pathStream('foo', {
11
12 // ignore any path where any part of the path begins with the letter 'c'
13 ignore: function(path) {
14 var pathParts = path.split('.');
15 var i;
16 for(i=0; i < pathParts.length; i++) {
17 if(pathParts[i].match(/^c/)) {
18 return true;
19 }
20 }
21 return false;
22 }
23 });
24 s.on('data', function(path) {
25 if(path === 'foo.cat') {
26 console.log("Error: Ignore appears to be broken.");
27 } else {
28 console.log(path);
29 }
30 });
31
32 s.on('end', function() {
33 cb();
34 });
35
36 s.on('error', function(err) {
37 cb(err);
38 });
39});
40