Skip to content

Commit

Permalink
Merge pull request #1657 from dart-lang/merge-stream_transform-package
Browse files Browse the repository at this point in the history
Merge `package:stream_transform`
  • Loading branch information
mosuem authored Dec 17, 2024
2 parents 84f7a11 + 80e4dfd commit 46cc745
Show file tree
Hide file tree
Showing 51 changed files with 5,922 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/stream_transform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:stream_transform"
about: "Create a bug or file a feature request against package:stream_transform."
labels: "package:stream_transform"
---
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
- changed-files:
- any-glob-to-any-file: 'pkgs/sse/**'

'package:stream_transform':
- changed-files:
- any-glob-to-any-file: 'pkgs/stream_transform/**'

'package:term_glyph':
- changed-files:
- any-glob-to-any-file: 'pkgs/term_glyph/**'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/clock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ on:
push:
branches: [ main ]
paths:
- '.github/workflows/clock.yml'
- '.github/workflows/clock.yaml'
- 'pkgs/clock/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/clock.yml'
- '.github/workflows/clock.yaml'
- 'pkgs/clock/**'
schedule:
- cron: "0 0 * * 0"
Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/stream_transform.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: package:stream_transform

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
paths:
- '.github/workflows/stream_transform.yaml'
- 'pkgs/stream_transform/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/stream_transform.yaml'
- 'pkgs/stream_transform/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github


defaults:
run:
working-directory: pkgs/stream_transform/

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

# Run tests on a matrix consisting of two dimensions:
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
# 2. release channel: dev
test:
needs: analyze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
# Bump SDK for Legacy tests when changing min SDK.
sdk: [3.1, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Run tests
run: dart test -p chrome,vm --test-randomize-ordering-seed=random
if: always() && steps.install.outcome == 'success'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ don't naturally belong to other topic monorepos (like
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
Expand Down
6 changes: 6 additions & 0 deletions pkgs/stream_transform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.pub/
.dart_tool/
build/
packages
pubspec.lock
.packages
185 changes: 185 additions & 0 deletions pkgs/stream_transform/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
## 2.1.1

- Require Dart 3.1 or greater
- Forward errors from the `trigger` future through to the result stream in
`takeUntil`. Previously an error would have not closed the stream, and instead
raised as an unhandled async error.
- Move to `dart-lang/tools` monorepo.

## 2.1.0

- Add `whereNotNull`.

## 2.0.1

- Require Dart 2.14 or greater.
- Wait for the future returned from `StreamSubscription.cancel()` before
listening to the subsequent stream in `switchLatest` and `switchMap`.

## 2.0.0

- Migrate to null safety.
- Improve tests of `switchMap` and improve documentation with links and
clarification.
- Add `trailing` argument to `throttle`.

## 1.2.0

- Add support for emitting the "leading" event in `debounce`.

## 1.1.1

- Fix a bug in `asyncMapSample`, `buffer`, `combineLatest`,
`combineLatestAll`, `merge`, and `mergeAll` which would cause an exception
when cancelling a subscription after using the transformer if the original
stream(s) returned `null` from cancelling their subscriptions.

## 1.1.0

- Add `concurrentAsyncExpand` to interleave events emitted by multiple sub
streams created by a callback.

## 1.0.0

- Remove the top level methods and retain the extensions only.

## 0.0.20

- Add extension methods for most transformers. These should be used in place
of the current methods. All current implementations are deprecated and will
be removed in the next major version bump.
- Migrating typical use: Instead of
`stream.transform(debounce(Duration(seconds: 1)))` use
`stream.debounce(Duration(seconds: 1))`.
- To migrate a usage where a `StreamTransformer` instance is stored or
passed see "Getting a StreamTransformer instance" on the README.
- The `map` and `chainTransformers` utilities are no longer useful with the
new patterns so they are deprecated without a replacement. If you still have
a need for them they can be replicated with `StreamTransformer.fromBind`:

```
// Replace `map(convert)`
StreamTransformer.fromBind((s) => s.map(convert));
// Replace `chainTransformers(first, second)`
StreamTransformer.fromBind((s) => s.transform(first).transform(second));
```
## 0.0.19
- Add `asyncMapSample` transform.
## 0.0.18
- Internal cleanup. Passed "trigger" streams or futures now allow `<void>`
generic type rather than an implicit `dynamic>`
## 0.0.17
- Add concrete types to the `onError` callback in `tap`.
## 0.0.16+1
- Remove usage of Set literal which is not available before Dart 2.2.0
## 0.0.16
- Allow a `combine` callback to return a `FutureOr<T>` in `scan`. There are no
behavior changes for synchronous callbacks. **Potential breaking change** In
the unlikely situation where `scan` was used to produce a `Stream<Future>`
inference may now fail and require explicit generic type arguments.
- Add `combineLatest`.
- Add `combineLatestAll`.
## 0.0.15
- Add `whereType`.
## 0.0.14+1
- Allow using non-dev Dart 2 SDK.
## 0.0.14
- `asyncWhere` will now forward exceptions thrown by the callback through the
result Stream.
- Added `concurrentAsyncMap`.
## 0.0.13
- `mergeAll` now accepts an `Iterable<Stream>` instead of only `List<Stream>`.
## 0.0.12
- Add `chainTransformers` and `map` for use cases where `StreamTransformer`
instances are stored as variables or passed to methods other than `transform`.
## 0.0.11
- Renamed `concat` as `followedBy` to match the naming of `Iterable.followedBy`.
`concat` is now deprecated.
## 0.0.10
- Updates to support Dart 2.0 core library changes (wave
2.2). See [issue 31847][sdk#31847] for details.
[sdk#31847]: https://github.com/dart-lang/sdk/issues/31847
## 0.0.9
- Add `asyncMapBuffer`.
## 0.0.8
- Add `takeUntil`.
## 0.0.7
- Bug Fix: Streams produced with `scan` and `switchMap` now correctly report
`isBroadcast`.
- Add `startWith`, `startWithMany`, and `startWithStream`.
## 0.0.6
- Bug Fix: Some transformers did not correctly add data to all listeners on
broadcast streams. Fixed for `throttle`, `debounce`, `asyncWhere` and `audit`.
- Bug Fix: Only call the `tap` data callback once per event rather than once per
listener.
- Bug Fix: Allow canceling and re-listening to broadcast streams after a
`merge` transform.
- Bug Fix: Broadcast streams which are buffered using a single-subscription
trigger can be canceled and re-listened.
- Bug Fix: Buffer outputs one more value if there is a pending trigger before
the trigger closes.
- Bug Fix: Single-subscription streams concatted after broadcast streams are
handled correctly.
- Use sync `StreamControllers` for forwarding where possible.
## 0.0.5
- Bug Fix: Allow compiling switchLatest with Dart2Js.
- Add `asyncWhere`: Like `where` but allows an asynchronous predicate.
## 0.0.4
- Add `scan`: fold which returns intermediate values
- Add `throttle`: block events for a duration after emitting a value
- Add `audit`: emits the last event received after a duration
## 0.0.3
- Add `tap`: React to values as they pass without being a subscriber on a stream
- Add `switchMap` and `switchLatest`: Flatten a Stream of Streams into a Stream
which forwards values from the most recent Stream
## 0.0.2
- Add `concat`: Appends streams in series
- Add `merge` and `mergeAll`: Interleaves streams
## 0.0.1
- Initial release with the following utilities:
- `buffer`: Collects events in a `List` until a `trigger` stream fires.
- `debounce`, `debounceBuffer`: Collect or drop events which occur closer in
time than a given duration.
27 changes: 27 additions & 0 deletions pkgs/stream_transform/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2017, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit 46cc745

Please sign in to comment.