convert-vinyl-to-vfile

Convert a Vinyl file to a VFile

Usage no npm install needed!

<script type="module">
  import convertVinylToVfile from 'https://cdn.skypack.dev/convert-vinyl-to-vfile';
</script>

README

convert-vinyl-to-vfile

NPM version Build Status Coverage Status

Code Climate Dependencies DevDependencies

Convert a Vinyl file to a VFile

Install

npm install --save convert-vinyl-to-vfile

Usage

const convertVinylToVfile = require('convert-vinyl-to-vfile')
const {join} = require('path');
const VFile = require('vfile');
const Vinyl = require('vinyl');

const vinylFile = new Vinyl({
  contents: Buffer.from('abe lincoln'),
  path: join('users', 'dustin', 'project', 'awesome.project.md')
});

const vfile = convertVinylToVfile(vinylFile);
/* =>
 * new VFile({
 *   contents: <Buffer 61 62 65 20 6c 69 6e 63 6f 6c 6e>,
 *   path: 'users/dustin/project/awesome.project.md'
 * })
 */

vfile instanceof VFile;
// => true

LICENSE

MIT © Dustin Specker