vinyl-collection

Create a collection for vinyl files.

Usage no npm install needed!

<script type="module">
  import vinylCollection from 'https://cdn.skypack.dev/vinyl-collection';
</script>

README

vinyl-collection NPM version NPM downloads Build Status

Create a collection for vinyl files.

Install

Install with npm:

$ npm install --save vinyl-collection

Usage

var Collection = require('vinyl-collection');

API

Collection

Create a new Collection with the given options.

Params

  • options {Object}

Example

var collection = new Collection();

.file

Create a vinyl file.

Params

  • key {String|Object}: Optionally define a key to use if the file will be cached.
  • file {Object}: Object or instance of [vinyl][].
  • returns {Object}

Example

var file = collection.file('foo', {path: 'a/b/c.js'});

.addFile

Add a file to the collection.

Params

  • key {String|Object}: Either the key to use for caching the file, or a [vinyl][] file object
  • file {Object}: Object or instance of Vinyl
  • returns {Object}: Returns the instance for chaining

Example

collection.addFile('foo', {path: 'a/b/c.js'});

.addFiles

Add an object or array of files to the collection.

Params

  • files {Array|Object}
  • returns {Object}: Returns the instance for chaining

Example

collection.addFiles(files);

.getFile

Get a file from the collection.

Params

  • key {String|Object}: The key of the file to get. If key is a file object it is returned.
  • returns {Object}: Returns the file if found

Example

var file = collection.getFile('foo');

.isFile

Returns true if file is a collection file object.

Params

  • file {Object}
  • returns {Boolean}

Example

console.log(collection.isFile('foo'));
//=> false

console.log(collection.isFile(new Vinyl({path: 'foo'})));
//=> false

console.log(collection.isFile(collection.file({path: 'foo'})));
//=> true

.isFile

Static method, returns true if file is a collection file object.

Params

  • file {Object}
  • returns {Boolean}

Example

console.log(Collection.isFile('foo'));
//=> false

console.log(Collection.isFile(new Vinyl({path: 'foo'})));
//=> false

console.log(Collection.isFile(collection.file({path: 'foo'})));
//=> true

Contributing

This document was generated by [verb-readme-generator][] (a verb generator), please don't edit directly. Any changes to the readme must be made in .verb.md. See Building Docs.

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. Or visit the [verb-readme-generator][] project to submit bug reports or pull requests for the readme layout template.

Building docs

Generate readme and API documentation with verb:

$ npm install -g verb verb-readme-generator && verb

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb, v0.9.0, on June 15, 2016.