Package Exports
- to-vfile
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 (to-vfile) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
to-vfile

Create a vfile from a file-path.
Installation
npm:
npm install to-vfileto-vfile is also available for bower, component, and duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.
Note: browser-builds do not include
readandreadSync.
Usage
var toVFile = require('to-vfile');
var file = toVFile('./readme.md');
/*
* { contents: '',
* filename: 'readme',
* directory: '.',
* extension: 'md',
* messages: [],
* __proto__: [VFile] }
*/
toVFile.read('.git/HEAD', function (err, file) {
if (err) throw err;
console.log(file);
/*
* { contents: 'ref: refs/heads/master\n',
* filename: 'HEAD',
* directory: '.git',
* extension: '',
* messages: [],
* __proto__: [VFile] }
*/
});
var file = toVFile.readSync('.gitignore')
/*
* { contents: '.DS_Store\n*.log\nbower_components/\nbuild/\ncomponents/\nnode_modules/\ncoverage/\nbuild.js\n',
* filename: '.gitignore',
* directory: '.',
* extension: '',
* messages: [],
* __proto__: [VFile] }
*/API
toVFile(filePath)
Create a virtual file from filePath.
Signatures
file = toVFile(filePath).
Parameters
filePath(string) — Path to a (possibly non-existent) file;
Returns
vfile — Instance.
toVFile.read(filePath, done)
Create a virtual file from filePath and fill it with the actual contents
at filePath.
Signatures
toVFile.read(filePath, callback).
Parameters
filePath(string) — Path to a (possibly non-existent) file;callback— Seefunction done(err, vfile).
Returns
vfile — Instance.
function done(err, vfile)
Callback.
Signatures
function done(Error, null);function done(null, VFile).
Parameters
err(Error) — Error from readingfilePath;vfile(VFile) — Virtual file.
toVFile.readSync(filePath)
Create a virtual file from filePath and fill it with the actual contents at
filePath (synchroneously).
Signatures
toVFile.read(filePath, callback).
Parameters
filePath(string) — Path to a (possibly non-existent) file;
Returns
vfile — Instance.
Throw
Error — When reading filePath fails.