Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

assemble-streams

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assemble-streams - npm Package Compare versions

Comparing version 0.7.0 to 1.0.0

128

index.js
/*!
* assemble-streams <https://github.com/jonschlinkert/assemble-streams>
* assemble-streams <https://github.com/assemble/assemble-streams>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
* Copyright (c) 2015-2017, Jon Schlinkert.
* Released under the MIT License.
*/

@@ -13,19 +13,24 @@

module.exports = function(options) {
return function appPlugin(app) {
if (!utils.isValid(app, 'assemble-streams')) return appPlugin;
app.define('toStream', appStream(app));
return function plugin(app) {
if (utils.isValid(app, 'assemble-streams')) {
app.define('toStream', appStream(app));
app.on('view', function(view) {
viewPlugin.call(view, view);
});
return collectionPlugin;
}
return function collectionPlugin(collection) {
if (!utils.isValid(collection, 'assemble-streams-collection', ['views', 'collection'])) {
return collectionPlugin;
function collectionPlugin(collection) {
if (utils.isValid(collection, 'assemble-streams', ['collection'])) {
collection.define('toStream', collectionStream(app, this));
}
collection.define('toStream', collectionStream(app, this));
return viewPlugin;
}
return function viewPlugin(view) {
if (!utils.isValid(view, 'assemble-streams-view', ['view', 'item', 'file'])) {
return viewPlugin;
}
this.define('toStream', viewStream(app));
};
};
function viewPlugin(view) {
if (utils.isValid(this, 'assemble-streams', ['item', 'file'])) {
utils.define(this, 'toStream', viewStream(app));
}
}
return plugin;
};

@@ -50,3 +55,5 @@ };

function appStream(app) {
initHandlers(app);
if (!hasHandler(app, 'onStream')) {
app.handler('onStream');
}

@@ -63,3 +70,4 @@ return function(name, filterFn) {

var write = writeStream(stream);
var views = tryGetViews(this, name);
var collection = this[name];
var views = collection && collection.views;

@@ -76,3 +84,3 @@ if (!views && typeof name !== 'undefined') {

return utils.src(stream.pipe(utils.handle.once(this, 'onStream')));
return outStream(stream, this);
}

@@ -85,3 +93,3 @@

return utils.src(stream.pipe(utils.handle.once(this, 'onStream')));
return outStream(stream, this);
};

@@ -105,4 +113,6 @@ }

function collectionStream(app, collection) {
initHandlers(collection);
function collectionStream(collection) {
if (!hasHandler(collection, 'onStream')) {
collection.handler('onStream');
}

@@ -121,3 +131,3 @@ return function(filterFn) {

return utils.src(stream.pipe(utils.handle.once(app, 'onStream')));
return outStream(stream, collection);
};

@@ -142,48 +152,20 @@ }

function viewStream(app) {
function viewStream(view) {
return function() {
var stream = utils.through.obj();
stream.setMaxListeners(0);
setImmediate(function(view) {
stream.write(view);
setImmediate(function(item) {
stream.write(item);
stream.end();
}, this);
return utils.src(stream.pipe(utils.handle.once(app, 'onStream')));
return outStream(stream, view);
};
}
function tryGetViews(app, name) {
try {
return app.getViews(name);
} catch (err) {}
}
function filter(key, view, fn) {
if (Array.isArray(fn)) {
var len = fn.length;
var idx = -1;
while (++idx < len) {
var name = fn[idx];
if (utils.match(name, view)) {
return true;
}
}
return false;
}
if (typeof fn === 'function') {
return fn(key, view);
}
if (typeof fn === 'string') {
return utils.match(fn, view);
}
return true;
}
function writeStream(stream) {
return function(views, filterFn) {
for (var key in views) {
if (!filter(key, views[key], filterFn)) {
continue;
if (filter(key, views[key], filterFn)) {
stream.write(views[key]);
}
stream.write(views[key]);
}

@@ -193,6 +175,30 @@ };

function initHandlers(app) {
if (typeof app.handler === 'function' && typeof app.onStream !== 'function') {
app.handler('onStream');
function outStream(stream, instance) {
return utils.src(stream.pipe(utils.handle.once(instance, 'onStream')));
}
function hasHandler(app, name) {
return typeof app.handler === 'function' && typeof app[name] === 'function';
}
function filter(key, view, val) {
switch (utils.typeOf(val)) {
case 'array':
var len = val.length;
var idx = -1;
while (++idx < len) {
var name = val[idx];
if (utils.match(name, view)) {
return true;
}
}
return false;
case 'function':
return val(key, view);
case 'string':
return utils.match(val, view);
default: {
return true;
}
}
}
{
"name": "assemble-streams",
"description": "Assemble pipeline plugin for pushing a view collection into a vinyl stream.",
"version": "0.7.0",
"description": "Assemble pipeline plugin for pushing views into a vinyl stream.",
"version": "1.0.0",
"homepage": "https://github.com/assemble/assemble-streams",

@@ -14,4 +14,2 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"index.js",
"LICENSE",
"README.md",
"utils.js"

@@ -28,13 +26,15 @@ ],

"assemble-handle": "^0.1.3",
"is-valid-app": "^0.2.0",
"lazy-cache": "^2.0.1",
"match-file": "^0.2.0",
"define-property": "^0.2.5",
"is-valid-app": "^0.2.1",
"kind-of": "^3.1.0",
"lazy-cache": "^2.0.2",
"match-file": "^0.2.1",
"src-stream": "^0.1.1",
"through2": "^2.0.1"
"through2": "^2.0.3"
},
"devDependencies": {
"assemble-fs": "^0.4.7",
"gulp-format-md": "^0.1.9",
"mocha": "^2.5.1",
"templates": "^0.18.3"
"assemble-fs": "^1.0.0",
"gulp-format-md": "^0.1.11",
"mocha": "^3.2.0",
"templates": "^1.2.6"
},

@@ -44,4 +44,20 @@ "keywords": [

"assembleplugin",
"boilerplate",
"build",
"cli",
"cli-app",
"collection",
"command-line",
"create",
"dev",
"development",
"framework",
"front",
"frontend",
"plugin",
"project",
"projects",
"scaffold",
"scaffolder",
"scaffolding",
"source",

@@ -51,3 +67,8 @@ "src",

"streams",
"vinyl"
"template",
"templates",
"vinyl",
"webapp",
"yeoman",
"yo"
],

@@ -54,0 +75,0 @@ "verb": {

@@ -1,4 +0,4 @@

# assemble-streams [![NPM version](https://img.shields.io/npm/v/assemble-streams.svg?style=flat)](https://www.npmjs.com/package/assemble-streams) [![NPM downloads](https://img.shields.io/npm/dm/assemble-streams.svg?style=flat)](https://npmjs.org/package/assemble-streams) [![Build Status](https://img.shields.io/travis/assemble/assemble-streams.svg?style=flat)](https://travis-ci.org/assemble/assemble-streams)
# assemble-streams [![NPM version](https://img.shields.io/npm/v/assemble-streams.svg?style=flat)](https://www.npmjs.com/package/assemble-streams) [![NPM monthly downloads](https://img.shields.io/npm/dm/assemble-streams.svg?style=flat)](https://npmjs.org/package/assemble-streams) [![NPM total downloads](https://img.shields.io/npm/dt/assemble-streams.svg?style=flat)](https://npmjs.org/package/assemble-streams) [![Linux Build Status](https://img.shields.io/travis/assemble/assemble-streams.svg?style=flat&label=Travis)](https://travis-ci.org/assemble/assemble-streams)
Assemble pipeline plugin for pushing a view collection into a vinyl stream.
> Assemble pipeline plugin for pushing views into a vinyl stream.

@@ -43,3 +43,3 @@ ## Install

### [app.toStream](index.js#L48)
### [app.toStream](index.js#L53)

@@ -62,3 +62,3 @@ Push a view collection into a vinyl stream.

### [collection.toStream](index.js#L100)
### [collection.toStream](index.js#L108)

@@ -80,3 +80,3 @@ Push a view collection into a vinyl stream.

### [view.toStream](index.js#L135)
### [view.toStream](index.js#L145)

@@ -109,10 +109,17 @@ Push the current view into a vinyl stream.

### Contributors
| **Commits** | **Contributor** |
| --- | --- |
| 34 | [jonschlinkert](https://github.com/jonschlinkert) |
| 21 | [doowb](https://github.com/doowb) |
### Building docs
_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
To generate the readme, run the following command:
```sh
$ npm install -g verb verb-generate-readme && verb
$ npm install -g verbose/verb#dev verb-generate-readme && verb
```

@@ -122,6 +129,6 @@

Install dev dependencies:
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
```sh
$ npm install -d && npm test
$ npm install && npm test
```

@@ -134,11 +141,11 @@

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
### License
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/assemble/assemble-streams/blob/master/LICENSE).
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
MIT
***
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.28, on August 02, 2016._
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 11, 2017._

@@ -12,3 +12,5 @@ 'use strict';

require('assemble-handle', 'handle');
require('define-property', 'define');
require('is-valid-app', 'isValid');
require('kind-of', 'typeOf');
require('match-file', 'match');

@@ -15,0 +17,0 @@ require('src-stream', 'src');

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc