@klodianimeri/pipejs
Version:
Pipe functions that provide convenient and efficient ways to work with iterators.
14 lines (13 loc) • 444 B
text/typescript
import { Pipe } from "../pipe.js";
import { Yields, push } from "../util/index.js";
export function endWith(...elements: Array<any>): Pipe {
return () => {
return (result: IteratorResult<any>): IteratorResult<any> | Array<IteratorResult<any>> => {
if (result.done) {
return push(Yields(elements), result);
} else {
return result;
}
};
}
}