vfile-glob

1.0.0 • Public • Published

vfile-glob

npm version Build Status Build status Coverage Status

Search files with glob pattern and create VFile objects from them

const vfileGlob = require('vfile-glob');
 
vfileGlob('index.*').subscribe({
  start() {
    console.log('Glob started.');
  },
  next(file) {
    file;
    /*=> VFile {
      data: {},
      messages: [],
      history: ['index.js'],
      cwd: '/Users/shinnn/github/vfile-glob',
      contents: <Buffer ... >
    } */
  },
  complete() {
    console.log('Glob completed.');
  }
});

Installation

Use npm.

npm install vfile-glob

API

const vfileGlob = require('vfile-glob');

vfileGlob(pattern [, options])

pattern: string (glob pattern)
options: Object (read-glob options) or string (encoding)
Return: Observable (zenparsing's implementation)

When the Observable is subscribed, it starts searching files matching the given glob pattern, create VFiles from matched files and successively sends them to its Observer.

vfileGlob('hi.txt').subscribe(file => {
  file.cwd; //=> '/Users/example'
  file.path; //=> 'hi.txt',
  file.contents; //=> <Buffer 48 69>
});
 
vfileGlob('exmaple/hi.txt', {
  cwd: '..',
  encoding: 'utf8'
}).subscribe(file => {
  file.cwd; //=> '/Users'
  file.path; //=> 'example/hi.txt'
  file.contents; //=> 'Hi'
});

License

ISC License © 2018 Shinnosuke Watanabe

Package Sidebar

Install

npm i vfile-glob

Weekly Downloads

1,043

Version

1.0.0

License

ISC

Unpacked Size

4.32 kB

Total Files

4

Last publish

Collaborators

  • shinnn