I want to selectively pass certain count of items in the pipeline, terminate the process block when the count is reached to avoid redundant spinning on unwanted items, like the following function:
function first5 {
begin {
$count = 0
}
process {
if (++$count -gt 5) {
break # ??
}
$_
}
}
The result is fine but measure doesn't seem to be able to capture them, does it mean the pipeline is terminated so measure received nothing?
1..10 | first5 # 1..5
1..10 | first5 | measure # none