Skip to content

Commit fec7cda

Browse files
committed
Add tee method to Query.
1 parent 796f51c commit fec7cda

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

jsonpath/fluent_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,10 @@ def last(self) -> Optional[JSONPathMatch]:
123123
return next(iter(self.tail(1)))
124124
except StopIteration:
125125
return None
126+
127+
def tee(self, n: int = 2) -> Tuple[Query, ...]:
128+
"""Return _n_ independent queries by teeing this query's match iterable.
129+
130+
It is not safe to use a `Query` instance after calling `tee()`.
131+
"""
132+
return tuple(Query(it) for it in itertools.tee(self._it, n))

0 commit comments

Comments
 (0)