Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/vfile-glob
Search files with glob pattern and create VFile objects from them
https://github.com/shinnn/vfile-glob
Last synced: 26 days ago
JSON representation
Search files with glob pattern and create VFile objects from them
- Host: GitHub
- URL: https://github.com/shinnn/vfile-glob
- Owner: shinnn
- License: isc
- Created: 2018-03-29T09:30:45.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-03-29T09:58:56.000Z (over 6 years ago)
- Last Synced: 2024-10-10T06:36:17.027Z (about 1 month ago)
- Language: JavaScript
- Size: 22.5 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vfile-glob
[![npm version](https://img.shields.io/npm/v/vfile-glob.svg)](https://www.npmjs.com/package/vfile-glob)
[![Build Status](https://travis-ci.org/shinnn/vfile-glob.svg?branch=master)](https://travis-ci.org/shinnn/vfile-glob)
[![Build status](https://ci.appveyor.com/api/projects/status/8jwxugh978gw12it/branch/master?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/vfile-glob/branch/master)
[![Coverage Status](https://img.shields.io/coveralls/shinnn/vfile-glob.svg)](https://coveralls.io/github/shinnn/vfile-glob)Search files with [glob](https://github.com/isaacs/node-glob#glob-primer) pattern and create [VFile](https://github.com/vfile/vfile) objects from them
```javascript
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:
} */
},
complete() {
console.log('Glob completed.');
}
});
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).
```
npm install vfile-glob
```## API
```javascript
const vfileGlob = require('vfile-glob');
```### vfileGlob(*pattern* [, *options*])
*pattern*: `string` (glob pattern)
*options*: `Object` ([`read-glob`](https://github.com/shinnn/node-read-glob) options) or `string` (encoding)
Return: [`Observable`](https://github.com/tc39/proposal-observable#observable) ([zenparsing's implementation](https://github.com/zenparsing/zen-observable))When the `Observable` is [subscribe](https://tc39.github.io/proposal-observable/#observable-prototype-subscribe)d, it starts searching files matching the given glob pattern, create [`VFile`](https://github.com/vfile/vfile#vfileoptions)s from matched files and successively sends them to its [`Observer`](https://github.com/tc39/proposal-observable#observer).
```javascript
vfileGlob('hi.txt').subscribe(file => {
file.cwd; //=> '/Users/example'
file.path; //=> 'hi.txt',
file.contents; //=>
});vfileGlob('exmaple/hi.txt', {
cwd: '..',
encoding: 'utf8'
}).subscribe(file => {
file.cwd; //=> '/Users'
file.path; //=> 'example/hi.txt'
file.contents; //=> 'Hi'
});
```## License
[ISC License](./LICENSE) © 2018 Shinnosuke Watanabe