diff --git a/modules/nextflow/src/main/groovy/nextflow/extension/OperatorImpl.groovy b/modules/nextflow/src/main/groovy/nextflow/extension/OperatorImpl.groovy index c1602a9569..6df669a04d 100644 --- a/modules/nextflow/src/main/groovy/nextflow/extension/OperatorImpl.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/extension/OperatorImpl.groovy @@ -1493,4 +1493,20 @@ class OperatorImpl { log.warn "Operator `fork` has been renamed to `multiMap`" multiMap(source, action) } + + /** + * Implement a `withOp` operator e.g. + *
+     *     someChannel | withOp { someProcess(it, someChannel) }
+           someChannel | withOp { someProcess(someChannel, it) }
+           someChannel | withOp { someChannel.someOperator(it) }
+     * 
+ * + * @param source The channel instance to be bound in the context + * @param closure A closure defining the operation/process to call + */ + + Object withOp(final DataflowReadChannel source, Closure closure) { + source.with(closure) + } }