JSPM

vinyl-readfile-promise

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

Promise to create a vinyl file object from an actual file

Package Exports

  • vinyl-readfile-promise

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

Readme

vinyl-readfile-promise

NPM version Build Status Build status Coverage Status Dependency Status devDependency Status

Promises/A+ version of vinyl-file:

Create a vinyl file from an actual file

var vinylReadFile = require('vinyl-readfile-promise');

vinylReadFile('index.js')
.then(function(file) {
  file.path; //=> /root/dir/index.js
  file.cwd; //=> /root/dir
})
.catch(), function(err) {
  throw err;
});

Installation

Use npm.

npm install vinyl-readfile-promise

API

var vinylReadFile = require('vinyl-readfile-promise');

vinylReadFile(filePath [, options])

filePath: String
options: Object (directly passed to vinyl-file options)
Return: Object (Promise)

When it finish reading a file, it will be fulfilled with a vinyl file object as an argument.

When it fails to read a file, it will be rejected with an error as an argument.

var vinylReadFile = require('vinyl-readfile-promise');

function onFulFilled(file) {
  file.isNull(); //=> false
  file.isBuffer(); //=> false
  file.isBuffer(); //=> true
}

function onRejected(err) {
  throw err;
}

vinylReadFile('path/to/file', {buffer: false}).then(onFulFilled, onRejected);

License

Copyright (c) Shinnosuke Watanabe

Licensed under the MIT License.