Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import sys
from collections import deque
from contextlib import closing
import typing


class Pipe:
Expand Down Expand Up @@ -251,6 +252,12 @@ def batched(iterable, n):
yield batch


@Pipe
def cast(iterable, type_):
"""Cast an iterable to a given type."""
return typing.cast(type_, iterable)


chain = Pipe(itertools.chain.from_iterable)
chain_with = Pipe(itertools.chain)
islice = Pipe(itertools.islice)
Expand Down
Loading