Skip to content

update to allow passing args to tap#19

Open
patrick-rodgers wants to merge 3 commits intogeejs:masterfrom
patrick-rodgers:master
Open

update to allow passing args to tap#19
patrick-rodgers wants to merge 3 commits intogeejs:masterfrom
patrick-rodgers:master

Conversation

@patrick-rodgers
Copy link

@patrick-rodgers patrick-rodgers commented Dec 8, 2017

This update allows the passing of an argument variable through to the lambda method. The argument can be a single value, array, or object - it is naively passed to the lambda. This addresses issue #17.

function myFunc(file, t, n, arg) {
//    arg === { t: 1 }
}

// gulp pipe omitted ...
tap(myFunc, { t: 1 })

Updated to also allow this:

function myFunc(file, t, n, arg, arg2, arg3) {
//    arg === { t: 1 }
// arg2 === "foo"
// arg3 === "bar"
}

// gulp pipe omitted ...
tap(myFunc, { t: 1 }, "foo", "bar")

@dotnetCarpenter
Copy link
Collaborator

@patrick-rodgers Thank you very much for your contribution. Will you please add two tests for this?

Bonus if you have a use-case you can link to so we can put it in the wiki and write about the motivation for this feature in the next release.

Thanks

@patrick-rodgers
Copy link
Author

Added the tests to cover calling tap with 0, 1, or 2 args. As for a usecase you can have a look at where I used it in a task to build docs. I needed to grab the header and footer for each article and wanted to only get them once to pass them on to the function to create the html article.

@patrick-rodgers
Copy link
Author

Oh, and all the tests pass, but please do have a look as CoffeeScript is new to me so always possible I am not actually calling anything :)

@dotnetCarpenter dotnetCarpenter self-assigned this Jan 4, 2018
dotnetCarpenter added a commit that referenced this pull request Aug 19, 2019
@dotnetCarpenter dotnetCarpenter added this to the 2.1.0 milestone Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants