JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 104370
  • Score
    100M100P100Q146694F
  • License MIT

Set the `contents` property on a file object in a stream.

Package Exports

  • file-contents

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

Readme

file-contents NPM version

Set the contents property on a file object in a stream.

Install

Install with npm

$ npm i file-contents --save

Usage

var through = require('through2');
var contents = require('file-contents');

function toStream(fp) {
  var stream = through.obj();
  stream.write({path: fp});
  stream.end();
  return stream;
}

toStream('README.md')
  .pipe(contents())
  .on('data', function (file) {
    // adds `contents` object to file
    console.log(file.contents.toString());
  })
  .on('end', function () {
    console.log('Done.');
  });

async

A .getContent() method is exposed for non-stream usage.

stats.getContent({path: 'README.md'}, function (err, res) {
  // Buffer.isBuffer(file.contents) => true
});
  • file-stat: Set the stat property on a file object in a stream.
  • stream-loader: create a read stream from a glob of files. can be used as a loader-cache… more
  • vinyl: A virtual file format
  • vinyl-fs: Vinyl adapter for the file system

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on July 14, 2015.