level-glob
A read stream filtered and ordered by glob patterns
Last updated 5 years ago by vweevers .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install level-glob 
SYNC missed versions from official npm registry.

level-glob

Create a read stream filtered and ordered by glob patterns. The keys in the database should be absolute, unix-like paths.

npm status Travis build status AppVeyor build status Dependency status

Jump to: usage / install / license

example

var level  = require('level-test')({ mem: true })
  , glob   = require('level-glob')
  , 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')
    }))

})

usage

glob(db, patterns(s)[, options])

Create a readstream filtered by one or more glob patterns.

glob.install(db)

Add a createGlobStream method to db.

glob.install(db);
db.createGlobStream('/**/*.png', options);

install

With npm do:

npm install level-glob

license

MIT © Vincent Weevers

Current Tags

  • 1.0.0                                ...           latest (5 years ago)

2 Versions

  • 1.0.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dev Dependencies (3)

Copyright 2014 - 2016 © taobao.org |