JBlam.Collections.Streams
0.0.1-testing
dotnet add package JBlam.Collections.Streams --version 0.0.1-testing
NuGet\Install-Package JBlam.Collections.Streams -Version 0.0.1-testing
<PackageReference Include="JBlam.Collections.Streams" Version="0.0.1-testing" />
<PackageVersion Include="JBlam.Collections.Streams" Version="0.0.1-testing" />
<PackageReference Include="JBlam.Collections.Streams" />
paket add JBlam.Collections.Streams --version 0.0.1-testing
#r "nuget: JBlam.Collections.Streams, 0.0.1-testing"
#:package JBlam.Collections.Streams@0.0.1-testing
#addin nuget:?package=JBlam.Collections.Streams&version=0.0.1-testing&prerelease
#tool nuget:?package=JBlam.Collections.Streams&version=0.0.1-testing&prerelease
JBlam's Stream query API
It's kind of like Linq, but for streams.
See the runtime's github issue which has some discussion about basically this topic.
Why
I keep producing these silly tedious throwaway implementations of "truncating stream" mainly in test projects.
In this repo, you can also find some stream assertions, which I may want to spin out into an assertion project at some point.
ReadStream
A mostly-virtual Stream, where the only fully-abstract API point is int Read(Span<byte>).
ValueTask<int> ReadAsync(Memory<byte>, CancellationToken)virtually delegates to the sync method, but you're most welcome to override it.- virtual overrides of Write, Flush, Seek, Position, and Length all throw
NotImplementedException - All the "old style" (
byte[], int, int) methods are sealed and delegate to theSpanandMemorymethods.
Delegate and factory methods
Factory methods are on the static JBlam.Collections.Streams.StreamCreate class.
That's a terrible name, but it'd suck if I follow the Linq convention for
IEnmerableandIObservableI'd have a class calledStream, which would cause issues for people whousing System.IO, which is just about everyone.
Create(IEnumerable<Memory<byte>>)andCreate(IAsyncEnumerable<Memory<byte>>)build a stream out of enumerated segments. The latter may only be read asynchronously:Read(Span<byte>)throwsNotSupportedException.Create(Func<long,Span<byte>,int>)* and the equivalent async (ValueTask-returning) build a stream which invokes the delegate on eachReadcall.Emptyprovides an empty stream.* Formally, I made a custom delegate
SpanWriteAtPositionbecause it's not legal to put ref-structs likeSpan<byte>in generic type parameters.
Functional methods
Extension methods in the same StreamCreate class as above.
Takeworks like the Linq overloadEnumerable.Take<T>(this IEnumerable<T>, Range), except I let you use multipleRangeargs. Requires the sourceCanSeekand expectLengthto not throw. I consider "skip" to be redundant.Append,Prepend,Joincan concatenate streams.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.1-testing | 106 | 5/10/2025 |