Skip to content

Commit 46cc745

Browse files
authored
Merge pull request #1657 from dart-lang/merge-stream_transform-package
Merge `package:stream_transform`
2 parents 84f7a11 + 80e4dfd commit 46cc745

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5922
-2
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: "package:stream_transform"
3+
about: "Create a bug or file a feature request against package:stream_transform."
4+
labels: "package:stream_transform"
5+
---

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
- changed-files:
109109
- any-glob-to-any-file: 'pkgs/sse/**'
110110

111+
'package:stream_transform':
112+
- changed-files:
113+
- any-glob-to-any-file: 'pkgs/stream_transform/**'
114+
111115
'package:term_glyph':
112116
- changed-files:
113117
- any-glob-to-any-file: 'pkgs/term_glyph/**'

.github/workflows/clock.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ on:
55
push:
66
branches: [ main ]
77
paths:
8-
- '.github/workflows/clock.yml'
8+
- '.github/workflows/clock.yaml'
99
- 'pkgs/clock/**'
1010
pull_request:
1111
branches: [ main ]
1212
paths:
13-
- '.github/workflows/clock.yml'
13+
- '.github/workflows/clock.yaml'
1414
- 'pkgs/clock/**'
1515
schedule:
1616
- cron: "0 0 * * 0"
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: package:stream_transform
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ main ]
7+
paths:
8+
- '.github/workflows/stream_transform.yaml'
9+
- 'pkgs/stream_transform/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- '.github/workflows/stream_transform.yaml'
14+
- 'pkgs/stream_transform/**'
15+
schedule:
16+
- cron: "0 0 * * 0"
17+
18+
env:
19+
PUB_ENVIRONMENT: bot.github
20+
21+
22+
defaults:
23+
run:
24+
working-directory: pkgs/stream_transform/
25+
26+
jobs:
27+
# Check code formatting and static analysis on a single OS (linux)
28+
# against Dart dev.
29+
analyze:
30+
runs-on: ubuntu-latest
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
sdk: [dev]
35+
steps:
36+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
37+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
38+
with:
39+
sdk: ${{ matrix.sdk }}
40+
- id: install
41+
name: Install dependencies
42+
run: dart pub get
43+
- name: Check formatting
44+
run: dart format --output=none --set-exit-if-changed .
45+
if: always() && steps.install.outcome == 'success'
46+
- name: Analyze code
47+
run: dart analyze --fatal-infos
48+
if: always() && steps.install.outcome == 'success'
49+
50+
# Run tests on a matrix consisting of two dimensions:
51+
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
52+
# 2. release channel: dev
53+
test:
54+
needs: analyze
55+
runs-on: ${{ matrix.os }}
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
# Add macos-latest and/or windows-latest if relevant for this package.
60+
os: [ubuntu-latest]
61+
# Bump SDK for Legacy tests when changing min SDK.
62+
sdk: [3.1, dev]
63+
steps:
64+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
65+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
66+
with:
67+
sdk: ${{ matrix.sdk }}
68+
- id: install
69+
name: Install dependencies
70+
run: dart pub get
71+
- name: Run tests
72+
run: dart test -p chrome,vm --test-randomize-ordering-seed=random
73+
if: always() && steps.install.outcome == 'success'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ don't naturally belong to other topic monorepos (like
4040
| [source_maps](pkgs/source_maps/) | A library to programmatically manipulate source map files. | [![package issues](https://img.shields.io/badge/package:source_maps-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_maps) | [![pub package](https://img.shields.io/pub/v/source_maps.svg)](https://pub.dev/packages/source_maps) |
4141
| [source_span](pkgs/source_span/) | Provides a standard representation for source code locations and spans. | [![package issues](https://img.shields.io/badge/package:source_span-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_span) | [![pub package](https://img.shields.io/pub/v/source_span.svg)](https://pub.dev/packages/source_span) |
4242
| [sse](pkgs/sse/) | Provides client and server functionality for setting up bi-directional communication through Server Sent Events (SSE) and corresponding POST requests. | [![package issues](https://img.shields.io/badge/package:sse-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asse) | [![pub package](https://img.shields.io/pub/v/sse.svg)](https://pub.dev/packages/sse) |
43+
| [stream_transform](pkgs/stream_transform/) | A collection of utilities to transform and manipulate streams. | [![package issues](https://img.shields.io/badge/package:stream_transform-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Astream_transform) | [![pub package](https://img.shields.io/pub/v/stream_transform.svg)](https://pub.dev/packages/stream_transform) |
4344
| [term_glyph](pkgs/term_glyph/) | Useful Unicode glyphs and ASCII substitutes. | [![package issues](https://img.shields.io/badge/package:term_glyph-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aterm_glyph) | [![pub package](https://img.shields.io/pub/v/term_glyph.svg)](https://pub.dev/packages/term_glyph) |
4445
| [test_reflective_loader](pkgs/test_reflective_loader/) | Support for discovering tests and test suites using reflection. | [![package issues](https://img.shields.io/badge/package:test_reflective_loader-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atest_reflective_loader) | [![pub package](https://img.shields.io/pub/v/test_reflective_loader.svg)](https://pub.dev/packages/test_reflective_loader) |
4546
| [timing](pkgs/timing/) | A simple package for tracking the performance of synchronous and asynchronous actions. | [![package issues](https://img.shields.io/badge/package:timing-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atiming) | [![pub package](https://img.shields.io/pub/v/timing.svg)](https://pub.dev/packages/timing) |

pkgs/stream_transform/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.pub/
2+
.dart_tool/
3+
build/
4+
packages
5+
pubspec.lock
6+
.packages

pkgs/stream_transform/CHANGELOG.md

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
## 2.1.1
2+
3+
- Require Dart 3.1 or greater
4+
- Forward errors from the `trigger` future through to the result stream in
5+
`takeUntil`. Previously an error would have not closed the stream, and instead
6+
raised as an unhandled async error.
7+
- Move to `dart-lang/tools` monorepo.
8+
9+
## 2.1.0
10+
11+
- Add `whereNotNull`.
12+
13+
## 2.0.1
14+
15+
- Require Dart 2.14 or greater.
16+
- Wait for the future returned from `StreamSubscription.cancel()` before
17+
listening to the subsequent stream in `switchLatest` and `switchMap`.
18+
19+
## 2.0.0
20+
21+
- Migrate to null safety.
22+
- Improve tests of `switchMap` and improve documentation with links and
23+
clarification.
24+
- Add `trailing` argument to `throttle`.
25+
26+
## 1.2.0
27+
28+
- Add support for emitting the "leading" event in `debounce`.
29+
30+
## 1.1.1
31+
32+
- Fix a bug in `asyncMapSample`, `buffer`, `combineLatest`,
33+
`combineLatestAll`, `merge`, and `mergeAll` which would cause an exception
34+
when cancelling a subscription after using the transformer if the original
35+
stream(s) returned `null` from cancelling their subscriptions.
36+
37+
## 1.1.0
38+
39+
- Add `concurrentAsyncExpand` to interleave events emitted by multiple sub
40+
streams created by a callback.
41+
42+
## 1.0.0
43+
44+
- Remove the top level methods and retain the extensions only.
45+
46+
## 0.0.20
47+
48+
- Add extension methods for most transformers. These should be used in place
49+
of the current methods. All current implementations are deprecated and will
50+
be removed in the next major version bump.
51+
- Migrating typical use: Instead of
52+
`stream.transform(debounce(Duration(seconds: 1)))` use
53+
`stream.debounce(Duration(seconds: 1))`.
54+
- To migrate a usage where a `StreamTransformer` instance is stored or
55+
passed see "Getting a StreamTransformer instance" on the README.
56+
- The `map` and `chainTransformers` utilities are no longer useful with the
57+
new patterns so they are deprecated without a replacement. If you still have
58+
a need for them they can be replicated with `StreamTransformer.fromBind`:
59+
60+
```
61+
// Replace `map(convert)`
62+
StreamTransformer.fromBind((s) => s.map(convert));
63+
64+
// Replace `chainTransformers(first, second)`
65+
StreamTransformer.fromBind((s) => s.transform(first).transform(second));
66+
```
67+
68+
## 0.0.19
69+
70+
- Add `asyncMapSample` transform.
71+
72+
## 0.0.18
73+
74+
- Internal cleanup. Passed "trigger" streams or futures now allow `<void>`
75+
generic type rather than an implicit `dynamic>`
76+
77+
## 0.0.17
78+
79+
- Add concrete types to the `onError` callback in `tap`.
80+
81+
## 0.0.16+1
82+
83+
- Remove usage of Set literal which is not available before Dart 2.2.0
84+
85+
## 0.0.16
86+
87+
- Allow a `combine` callback to return a `FutureOr<T>` in `scan`. There are no
88+
behavior changes for synchronous callbacks. **Potential breaking change** In
89+
the unlikely situation where `scan` was used to produce a `Stream<Future>`
90+
inference may now fail and require explicit generic type arguments.
91+
- Add `combineLatest`.
92+
- Add `combineLatestAll`.
93+
94+
## 0.0.15
95+
96+
- Add `whereType`.
97+
98+
## 0.0.14+1
99+
100+
- Allow using non-dev Dart 2 SDK.
101+
102+
## 0.0.14
103+
104+
- `asyncWhere` will now forward exceptions thrown by the callback through the
105+
result Stream.
106+
- Added `concurrentAsyncMap`.
107+
108+
## 0.0.13
109+
110+
- `mergeAll` now accepts an `Iterable<Stream>` instead of only `List<Stream>`.
111+
112+
## 0.0.12
113+
114+
- Add `chainTransformers` and `map` for use cases where `StreamTransformer`
115+
instances are stored as variables or passed to methods other than `transform`.
116+
117+
## 0.0.11
118+
119+
- Renamed `concat` as `followedBy` to match the naming of `Iterable.followedBy`.
120+
`concat` is now deprecated.
121+
122+
## 0.0.10
123+
124+
- Updates to support Dart 2.0 core library changes (wave
125+
2.2). See [issue 31847][sdk#31847] for details.
126+
127+
[sdk#31847]: https://github.com/dart-lang/sdk/issues/31847
128+
129+
## 0.0.9
130+
131+
- Add `asyncMapBuffer`.
132+
133+
## 0.0.8
134+
135+
- Add `takeUntil`.
136+
137+
## 0.0.7
138+
139+
- Bug Fix: Streams produced with `scan` and `switchMap` now correctly report
140+
`isBroadcast`.
141+
- Add `startWith`, `startWithMany`, and `startWithStream`.
142+
143+
## 0.0.6
144+
145+
- Bug Fix: Some transformers did not correctly add data to all listeners on
146+
broadcast streams. Fixed for `throttle`, `debounce`, `asyncWhere` and `audit`.
147+
- Bug Fix: Only call the `tap` data callback once per event rather than once per
148+
listener.
149+
- Bug Fix: Allow canceling and re-listening to broadcast streams after a
150+
`merge` transform.
151+
- Bug Fix: Broadcast streams which are buffered using a single-subscription
152+
trigger can be canceled and re-listened.
153+
- Bug Fix: Buffer outputs one more value if there is a pending trigger before
154+
the trigger closes.
155+
- Bug Fix: Single-subscription streams concatted after broadcast streams are
156+
handled correctly.
157+
- Use sync `StreamControllers` for forwarding where possible.
158+
159+
## 0.0.5
160+
161+
- Bug Fix: Allow compiling switchLatest with Dart2Js.
162+
- Add `asyncWhere`: Like `where` but allows an asynchronous predicate.
163+
164+
## 0.0.4
165+
- Add `scan`: fold which returns intermediate values
166+
- Add `throttle`: block events for a duration after emitting a value
167+
- Add `audit`: emits the last event received after a duration
168+
169+
## 0.0.3
170+
171+
- Add `tap`: React to values as they pass without being a subscriber on a stream
172+
- Add `switchMap` and `switchLatest`: Flatten a Stream of Streams into a Stream
173+
which forwards values from the most recent Stream
174+
175+
## 0.0.2
176+
177+
- Add `concat`: Appends streams in series
178+
- Add `merge` and `mergeAll`: Interleaves streams
179+
180+
## 0.0.1
181+
182+
- Initial release with the following utilities:
183+
- `buffer`: Collects events in a `List` until a `trigger` stream fires.
184+
- `debounce`, `debounceBuffer`: Collect or drop events which occur closer in
185+
time than a given duration.

pkgs/stream_transform/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2017, the Dart project authors.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of Google LLC nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)