assemble-streams
Advanced tools
Comparing version 0.3.1 to 0.4.0
91
index.js
@@ -10,55 +10,58 @@ /*! | ||
var handle = require('assemble-handle'); | ||
var through = require('through2'); | ||
var src = require('src-stream'); | ||
module.exports = function(options) { | ||
var handle = require('assemble-handle'); | ||
var through = require('through2'); | ||
var src = require('src-stream'); | ||
module.exports = function fn(app) { | ||
return function fn(app) { | ||
if (this.isRegistered('streams')) return; | ||
/** | ||
* Push a view collection into a vinyl stream. | ||
* | ||
* ```js | ||
* app.toStream('posts', function(file) { | ||
* return file.path !== 'index.hbs'; | ||
* }) | ||
* ``` | ||
* @name .toStream | ||
* @param {String} `collection` Name of the collection to push into the stream. | ||
* @param {Function} Optionally pass a filter function to use for filtering views. | ||
* @return {Stream} | ||
* @api public | ||
*/ | ||
/** | ||
* Push a view collection into a vinyl stream. | ||
* | ||
* ```js | ||
* app.toStream('posts', function(file) { | ||
* return file.path !== 'index.hbs'; | ||
* }) | ||
* ``` | ||
* @name .toStream | ||
* @param {String} `collection` Name of the collection to push into the stream. | ||
* @param {Function} Optionally pass a filter function to use for filtering views. | ||
* @return {Stream} | ||
* @api public | ||
*/ | ||
app.mixin('toStream', function (name, filterFn) { | ||
var stream = through.obj(); | ||
stream.setMaxListeners(0); | ||
app.mixin('toStream', function (name, filterFn) { | ||
var stream = through.obj(); | ||
stream.setMaxListeners(0); | ||
if (typeof name === 'undefined' && !this.isCollection) { | ||
process.nextTick(stream.end.bind(stream)); | ||
return src(stream); | ||
} | ||
if (typeof name === 'undefined' && !this.isCollection) { | ||
process.nextTick(stream.end.bind(stream)); | ||
return src(stream); | ||
} | ||
var views; | ||
if (this.isApp && name) { | ||
views = this.getViews(name); | ||
} else { | ||
views = this.views; | ||
} | ||
var views; | ||
if (this.isApp && name) { | ||
views = this.getViews(name); | ||
} else { | ||
views = this.views; | ||
} | ||
setImmediate(function () { | ||
for (var key in views) { | ||
if (!filter(key, views[key], filterFn)) { | ||
continue; | ||
setImmediate(function () { | ||
for (var key in views) { | ||
if (!filter(key, views[key], filterFn)) { | ||
continue; | ||
} | ||
stream.write(views[key]); | ||
} | ||
stream.write(views[key]); | ||
} | ||
stream.end(); | ||
stream.end(); | ||
}); | ||
return src(stream).pipe(handle(this, 'onStream')); | ||
}); | ||
return src(stream).pipe(handle(this, 'onStream')); | ||
}); | ||
if (app.isApp) { | ||
return fn; | ||
} | ||
if (app.isApp) { | ||
return fn; | ||
} | ||
}; | ||
}; | ||
@@ -65,0 +68,0 @@ |
{ | ||
"name": "assemble-streams", | ||
"description": "Assemble pipeline plugin for pushing a view collection into a vinyl stream.", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"homepage": "https://github.com/jonschlinkert/assemble-streams", | ||
@@ -28,3 +28,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"devDependencies": { | ||
"assemble-core": "^0.8.1", | ||
"assemble-core": "^0.8.3", | ||
"gulp-format-md": "^0.1.5", | ||
@@ -31,0 +31,0 @@ "mocha": "*" |
@@ -5,2 +5,3 @@ # assemble-streams [![NPM version](https://img.shields.io/npm/v/assemble-streams.svg)](https://www.npmjs.com/package/assemble-streams) [![Build Status](https://img.shields.io/travis/jonschlinkert/assemble-streams.svg)](https://travis-ci.org/jonschlinkert/assemble-streams) | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
@@ -15,2 +16,10 @@ - [Related projects](#related-projects) | ||
## Install | ||
Install with [npm](https://www.npmjs.com/): | ||
```sh | ||
$ npm i assemble-streams --save | ||
``` | ||
## Usage | ||
@@ -68,2 +77,2 @@ | ||
_This file was generated by [verb](https://github.com/verbose/verb) on January 12, 2016._ | ||
_This file was generated by [verb](https://github.com/verbose/verb) on January 19, 2016._ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6670
62
75