-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
39 lines (30 loc) · 1.09 KB
/
example.js
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
31
32
33
34
35
36
37
38
39
var level = require('level-test')({ mem: true })
, glob = require('./')
, concat = require('concat-stream')
// create a database
var db = level()
// insert some data
var ops = [
{type: 'put', key: '/readme.md', value: 'readme' },
{type: 'put', key: '/assets/app.js', value: 'js' },
{type: 'put', key: '/assets/app.css', value: 'css' }
]
db.batch(ops, function(){
var opts = { values: true, keys: false }
// aggregates multiple streams
glob(db, ['assets/*', '/*'], opts).pipe(concat(function(value){
console.log(value === 'cssjsreadme')
}))
// but those streams are ordered
glob(db, ['/*', 'assets/*'], opts).pipe(concat(function(value){
console.log(value === 'readmecssjs')
}))
// negation only applies to patterns before it
glob(db, ['assets/*', '!**.md', '/*'], opts).pipe(concat(function(value){
console.log(value === 'cssjsreadme')
}))
// so this negative glob does have an effect
glob(db, ['assets/*', '/*', '!**.md'], opts).pipe(concat(function(value){
console.log(value === 'cssjs')
}))
})