-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
duplicate
method to both iterables
- Loading branch information
Showing
18 changed files
with
902 additions
and
419 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [polyethylene](./polyethylene.md) > [PolyAsyncIterable](./polyethylene.polyasynciterable.md) > [duplicate](./polyethylene.polyasynciterable.duplicate.md) | ||
|
||
## PolyAsyncIterable.duplicate() method | ||
|
||
Returns a tuple containing `num` iterables that will yield independent copies of the elements yielded by `this`<!-- -->. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
duplicate<N extends number>(num: N): Tuple<PolyAsyncIterable<T>, N>; | ||
``` | ||
## Parameters | ||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| num | N | the number of copies to be returned | | ||
**Returns:** | ||
[Tuple](./polyethylene.tuple.md)<!-- --><[PolyAsyncIterable](./polyethylene.polyasynciterable.md)<!-- --><T>, N> | ||
An array of `num` elements containing independent copies of this iterable | ||
## Remarks | ||
Note that, as with every other method of this class, this instance is unusable after calling this method. | ||
In order to provide a truly independent iteration for all returned iterables, a buffer is kept, which can grow as big as the whole iteration in certain circumstances. The buffer is filled as fast as the fastest iterable requests new items, and emptied as fast as the slowest iterable consumes those items. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [polyethylene](./polyethylene.md) > [PolySyncIterable](./polyethylene.polysynciterable.md) > [duplicate](./polyethylene.polysynciterable.duplicate.md) | ||
|
||
## PolySyncIterable.duplicate() method | ||
|
||
Returns a tuple containing `num` iterables that will yield independent copies of the elements yielded by `this`<!-- -->. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
duplicate<N extends number>(num: N): Tuple<PolySyncIterable<T>, N>; | ||
``` | ||
## Parameters | ||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| num | N | the number of copies to be returned | | ||
**Returns:** | ||
[Tuple](./polyethylene.tuple.md)<!-- --><[PolySyncIterable](./polyethylene.polysynciterable.md)<!-- --><T>, N> | ||
An array of `num` elements containing independent copies of this iterable | ||
## Remarks | ||
Note that, as with every other method of this class, this instance is unusable after calling this method. | ||
In order to provide a truly independent iteration for all returned iterables, a buffer is kept, which can grow as big as the whole iteration in certain circumstances. The buffer is filled as fast as the fastest iterable requests new items, and emptied as fast as the slowest iterable requests new items. | ||
Note that for synchronous iterations, it's common to end up with a full buffer if the returned duplicated elements are used in sequence. In this situation, it might be more useful to simply convert the iteration to an array and pass it around, rather than pay the overhead of this method. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [polyethylene](./polyethylene.md) > [Tuple](./polyethylene.tuple.md) | ||
|
||
## Tuple type | ||
|
||
A tuple of `N` elements of type `T`<!-- -->. | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export type Tuple<T, N extends number> = [T, ...T[]] & { | ||
length: N; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.