gulpjs / glob-stream

Readable streamx interface over anymatch.
MIT License
178 stars 53 forks source link

Should filtering be implemented as an option here? #66

Closed phated closed 8 years ago

phated commented 8 years ago

We support filtering files based on a timestamp in vinyl-fs. Maybe we should push that down to this layer by accepting a filter function in the options and applying it to each match before emitting it on the stream. The specifics about filtering by date could still be in vinyl-fs because it would be generating the filter function.

@contra what do you think about this?

yocontra commented 8 years ago

@phated Yeah, I agree. Do you want to expose that option in vinyl-fs though? How about async filter functions + stream ordering?

phated commented 8 years ago

I think vinyl-fs still exposes since option and we generate the filter method and pass it to glob-stream like globStream.create(globs, { filter: sinceFilter }). I guess we could also expose filter directly like { filter: options.filter || sinceFilter }

Not sure how we'd do stream ordering though.

erikkemperman commented 8 years ago

It might make sense to have a filter option here regardless, but I think that when I pass a function as since option to vinylfs.src(), I would expect it to be invoked with an actual vinyl argument, as the other options are (or will be).

So I don't think vinyl-fs/vinyl-prepare can simply hand this option off to glob-stream, because the corresponding vinyl object will not yet have been created at that time...?

phated commented 8 years ago

@erikkemperman good catch, we'll probably not push filter down into this project then.

phated commented 8 years ago

Going to close this since it doesn't feel appropriate to implement here. Might revisit in the future if alternative forms of filtering seem to make sense here.