-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
piping #94
Comments
You can pass a function to |
Hmm, but the function passed to transform takes input and output dirs or files, not nodes. It's not obvious to me how to do this sort of thing with |
File transformers take gobble( 'src' ).transform( code => '/* bird */' + code ).moveTo( 'place' ); |
Right, but I want compose existing transformations and reuse those compositions. I don't need to work directly with the strings. |
This is actually a common enough operation that there's been talk of adding a pipe operator into JS itself: https://github.com/mindeavor/es-pipeline-operator . That's a long way off though, so for now I could see the value of a pipe method for convenience. Biggest downside I see is that it increases the API surface area slightly. Re. monkey patching, I think you can grab any nodeInstance.constructor.prototype.pipe = function pipe(f) { return f(this); }; |
Yeah, I played around with that for a bit yesterday and was surprised that I couldn't quite get anything to work. But could easily have been user error. |
Odd. Give this a shot: gobble('').constructor.prototype.pipe = function pipe(f) { return f(this); }; [EDIT: huh yeah, I see what you mean; not working for me] |
OK... the gobble([]).__proto__.__proto__.pipe = function pipe(f) { return f(this); }; |
Ah, right, I should have figured that out. Thanks! |
Np!
|
One thing that frustrates me about the gobble API is that I can't figure out how to compose things. Specifically, I want to do something like this:
I think
pipe
is probably a very simple function onNode
that looks something like:So...is there:
a) a way I'm missing to accomplish this?
b) a way of hacking this in from userspace (I couldn't figure out how to monkey patch it)?
c) a chance you'd take that addition as a PR?
The text was updated successfully, but these errors were encountered: