Last active
December 21, 2015 06:19
-
-
Save phoenixenero/eac745a07f358eabb213 to your computer and use it in GitHub Desktop.
Creates a new anonymous function that when called, returns a new gulp-if pipe.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This returns an anonymous function that returns a new gulp-if pipe | |
// https://github.com/OverZealous/lazypipe#using-with-more-complex-function-arguments-such-as-gulp-if | |
function lazygulpif( condition, pipeFunction, args ) { | |
args = ! args ? [] : args; | |
args = args.constructor === Array ? args : [ args ]; | |
return function() { | |
return gulpif( condition, pipeFunction.apply( this, args ) ); | |
}; | |
} | |
// If else version | |
function lazygulpifelse( condition, | |
pipeFunction1, | |
pipeFunction2, | |
args1, | |
args2 ) { | |
args1 = ! args1 ? [] : args1; | |
args2 = ! args2 ? [] : args2; | |
args1 = args1.constructor === Array ? args1 : [ args1 ]; | |
args2 = args2.constructor === Array ? args2 : [ args2 ]; | |
return function() { | |
return gulpif( condition, | |
pipeFunction1.apply( this, args1 ), | |
pipeFunction2.apply( this, args2 ) ); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment