JSPM

vfile-glob

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 793
  • Score
    100M100P100Q110093F
  • License ISC

Search files with glob pattern and create VFile objects from them

Package Exports

  • vfile-glob

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (vfile-glob) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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