Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Use to create an immutable, lazily initialized pipeline from a series of streams.
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()()
).
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);
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.
(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.
FAQs
Use to create an immutable, lazily initialized pipeline from a series of streams.
We found that lazypipe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.