Socket
Socket
Sign inDemoInstall

lazypipe

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazypipe

Use to create an immutable, lazily initialized pipeline from a series of streams.


Version published
Maintainers
1
Created
Source

status

lazypipe

Lazypipe allows you to create an immutable, lazily-initialized pipeline. It's designed to be used in an environment where you want to reuse partial pipelines, such as with gulp.

This module returns a function that can be used to start building a lazypipe. Individual steps are added via the .pipe() method. At any point, a new lazypipe can be built by adding to an existing one, without affecting the previous lazypipe. Lazypipes can even be used as steps within another lazypipe.

Once the partial pipeline is ready to use, call the last result from .pipe() directly as a function (e.g.: .pipe()()).

Usage

Install using:

npm i --save-dev lazypipe

Then create lazypipes like so:

// Example usage within a gulpfile
var lazypipe = require('lazypipe');

...

// initialize a lazypipe
var jsHintTasks = lazypipe()
    // adding a pipeline step, notice the stream has not been initialized!
    .pipe(jshint)
    // adding a step with an argument
    .pipe(jshint.reporter, 'jshint-stylish');
 
// this is OK, because lazypipes are immutable
// jsHintTasks will _not_ be affected by the addition.
var jsTasks = jsHintTasks
    .pipe(gulp.dest, 'build/js');
 
// Create another pipe
var cssTasks = lazypipe()
    .pipe(recess, recessConfig)
    .pipe(less)
    .pipe(autoprefixer);


// now using the lazypipes
gulp.task('jsHint', function() {
    gulp.src('js/**/*.js').pipe(jsHintTasks());
});

gulp.task('build', function() {
    // for example only!
    return gulp.src('js/**/*.js').pipe(jsTasks());
});

gulp.task('default', ['build'], function() {
	// using gulp-watch
	watch('js/**/*.js').pipe(jsTasks());
});

You can combine lazypipes in various ways:

// streamA -> streamB
var foo = lazypipe().pipe(streamA).pipe(streamB);

// streamA -> streamB -> streamC
var bar = foo.pipe(streamC);

// streamD -> streamA -> streamB -> streamE
var baz = lazypipe().pipe(streamD).pipe(foo).pipe(streamE);

API

lazypipe()

Initializes a lazypipe. Returns a function that can be used to create the pipeline. The returned function has a function (pipe) which can be used to create new lazypipes with an additional step.

lazypipe().pipe(stream|fn, args...)

Creates a new lazy pipeline with all the previous steps, and the new step added to the end. Returns the new lazypipe.

  • stream or fn - a stream initializer or function to call when the pipeline is created later. You can provide your own custom functions if necessary.
  • args - Any remaining arguments are saved and passed into stream or fn when the pipeline is created.

lazypipe()() "Create"

Calling the result of pipe() as a function creates a pipeline at that time. This can be used multiple times, and can even be called if the lazypipe was added to for other purposes.

It returns a stream created using stream-combiner, where all the internal steps are processed sequentially, and the final result is passed on.

LICENSE

(MIT License)

Copyright (c) 2014 Phil DeJarnett

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 04 Feb 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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