New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@yume-chan/stream-extra

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yume-chan/stream-extra - npm Package Compare versions

Comparing version 0.0.18 to 0.0.19

esm/consumable.d.ts

54

CHANGELOG.json
{
"name": "@yume-chan/stream-extra",
"entries": [
{
"version": "0.0.18",
"tag": "@yume-chan/stream-extra_v0.0.18",
"date": "Wed, 25 Jan 2023 21:33:49 GMT",
"comments": {
"none": [
{
"comment": "Change to load native Web Streams API implementation from `globalThis` if available"
}
]
}
},
{
"version": "0.0.17",
"tag": "@yume-chan/stream-extra_v0.0.17",
"date": "Tue, 18 Oct 2022 09:32:30 GMT",
"comments": {}
}
]
"name": "@yume-chan/stream-extra",
"entries": [
{
"version": "0.0.19",
"tag": "@yume-chan/stream-extra_v0.0.19",
"date": "Sun, 09 Apr 2023 05:55:33 GMT",
"comments": {
"none": [
{
"comment": "Add an option to combine small chunks into target size in `ChunkStream`, and rename it to `DistributionStream`"
}
]
}
},
{
"version": "0.0.18",
"tag": "@yume-chan/stream-extra_v0.0.18",
"date": "Wed, 25 Jan 2023 21:33:49 GMT",
"comments": {
"none": [
{
"comment": "Change to load native Web Streams API implementation from `globalThis` if available"
}
]
}
},
{
"version": "0.0.17",
"tag": "@yume-chan/stream-extra_v0.0.17",
"date": "Tue, 18 Oct 2022 09:32:30 GMT",
"comments": {}
}
]
}
# Change Log - @yume-chan/stream-extra
This log was last generated on Wed, 25 Jan 2023 21:33:49 GMT and should not be manually modified.
This log was last generated on Sun, 09 Apr 2023 05:55:33 GMT and should not be manually modified.
## 0.0.19
Sun, 09 Apr 2023 05:55:33 GMT
### Updates
- Add an option to combine small chunks into target size in `ChunkStream`, and rename it to `DistributionStream`
## 0.0.18

@@ -16,2 +23,1 @@ Wed, 25 Jan 2023 21:33:49 GMT

_Initial release_

@@ -1,4 +0,5 @@

import { type ValueOrPromise } from "@yume-chan/struct";
import type { ValueOrPromise } from "@yume-chan/struct";
import { BufferedReadableStream } from "./buffered.js";
import { ReadableStream, WritableStream, type ReadableWritablePair } from "./stream.js";
import type { ReadableWritablePair } from "./stream.js";
import { ReadableStream, WritableStream } from "./stream.js";
export declare class BufferedTransformStream<T> implements ReadableWritablePair<T, Uint8Array> {

@@ -5,0 +6,0 @@ private _readable;

import { BufferedReadableStream, BufferedReadableStreamEndedError, } from "./buffered.js";
import { PushReadableStream, } from "./push-readable.js";
import { ReadableStream, WritableStream, } from "./stream.js";
import { PushReadableStream } from "./push-readable.js";
import { ReadableStream, WritableStream } from "./stream.js";
// TODO: BufferedTransformStream: find better implementation

@@ -5,0 +5,0 @@ export class BufferedTransformStream {

@@ -1,2 +0,2 @@

import { type ReadableStream, type ReadableStreamDefaultReader } from "./stream.js";
import type { ReadableStream, ReadableStreamDefaultReader } from "./stream.js";
export declare class BufferedReadableStreamEndedError extends Error {

@@ -9,2 +9,4 @@ constructor();

private bufferedLength;
private _position;
get position(): number;
protected readonly stream: ReadableStream<Uint8Array>;

@@ -11,0 +13,0 @@ protected readonly reader: ReadableStreamDefaultReader<Uint8Array>;

@@ -13,2 +13,6 @@ import { PushReadableStream } from "./push-readable.js";

bufferedLength = 0;
_position = 0;
get position() {
return this._position;
}
stream;

@@ -25,2 +29,3 @@ reader;

}
this._position += value.byteLength;
return value;

@@ -27,0 +32,0 @@ }

@@ -1,5 +0,8 @@

import { TransformStream } from "./stream.js";
export declare class ChunkStream extends TransformStream<Uint8Array, Uint8Array> {
constructor(size: number);
import { TransformStream } from "../src/stream.js";
export declare class DistributionStream extends TransformStream<
Uint8Array,
Uint8Array
> {
constructor(size: number, combine?: boolean);
}
//# sourceMappingURL=chunk.d.ts.map
//# sourceMappingURL=chunk.d.ts.map
import { TransformStream } from "./stream.js";
export class ChunkStream extends TransformStream {
constructor(size) {
export class DistributionStream extends TransformStream {
constructor(size, combine = false) {
let combineBuffer = combine ? new Uint8Array(size) : undefined;
let combineBufferOffset = 0;
let combineBufferAvailable = size;
super({
transform(chunk, controller) {
for (let start = 0; start < chunk.byteLength;) {
const end = start + size;
controller.enqueue(chunk.subarray(start, end));
start = end;
let offset = 0;
let available = chunk.byteLength;
if (combineBuffer && combineBufferOffset !== 0) {
if (available >= combineBufferAvailable) {
combineBuffer.set(chunk.subarray(0, combineBufferAvailable), combineBufferOffset);
offset += combineBufferAvailable;
available -= combineBufferAvailable;
controller.enqueue(combineBuffer);
combineBuffer = new Uint8Array(size);
combineBufferOffset = 0;
combineBufferAvailable = size;
if (available === 0) {
return;
}
}
else {
combineBuffer.set(chunk, combineBufferOffset);
combineBufferOffset += available;
combineBufferAvailable -= available;
return;
}
}
}
while (available >= size) {
const end = offset + size;
controller.enqueue(chunk.subarray(offset, end));
offset = end;
available -= size;
}
if (available > 0) {
if (combineBuffer) {
combineBuffer.set(chunk.subarray(offset), combineBufferOffset);
combineBufferOffset += chunk.byteLength - offset;
combineBufferAvailable -= chunk.byteLength - offset;
}
else {
controller.enqueue(chunk.subarray(offset));
}
}
},
flush(controller) {
if (combineBuffer && combineBufferOffset !== 0) {
controller.enqueue(combineBuffer.subarray(0, combineBufferOffset));
}
},
});

@@ -13,0 +54,0 @@ }

@@ -0,0 +0,0 @@ import { TransformStream } from "./stream.js";

@@ -0,0 +0,0 @@ import { decodeUtf8 } from "@yume-chan/struct";

@@ -1,3 +0,4 @@

import { type ValueOrPromise } from "@yume-chan/struct";
import { WritableStream, type ReadableStream } from "./stream.js";
import type { ValueOrPromise } from "@yume-chan/struct";
import type { ReadableStream } from "./stream.js";
import { WritableStream } from "./stream.js";
import { WrapReadableStream } from "./wrap-readable.js";

@@ -4,0 +5,0 @@ export interface DuplexStreamFactoryOptions {

import { PromiseResolver } from "@yume-chan/async";
import { WritableStream, } from "./stream.js";
import { WritableStream } from "./stream.js";
import { WrapReadableStream } from "./wrap-readable.js";
const NOOP = () => {
// no-op
};
/**

@@ -32,3 +35,3 @@ * A factory for creating a duplex stream.

cancel: async () => {
// cancel means the local peer closes the connection first.
// cancel means the local peer wants to close the connection.
await this.close();

@@ -49,3 +52,2 @@ },

write: async (chunk) => {
await writer.ready;
await writer.write(chunk);

@@ -58,5 +60,3 @@ },

close: async () => {
await writer.close().catch((e) => {
void e;
});
await writer.close().catch(NOOP);
await this.close();

@@ -77,5 +77,3 @@ },

for (const writer of this.writers) {
await writer.close().catch((e) => {
void e;
});
await writer.close().catch(NOOP);
}

@@ -90,4 +88,4 @@ }

}
catch (e) {
void e;
catch {
// ignore
}

@@ -94,0 +92,0 @@ }

@@ -0,0 +0,0 @@ import { WritableStream } from "./stream.js";

import { WritableStream } from "./stream.js";
export class GatherStringStream extends WritableStream {
// PERF: rope (concat strings) is faster than `[].join('')`
_result = '';
get result() { return this._result; }
_result = "";
get result() {
return this._result;
}
constructor() {

@@ -7,0 +9,0 @@ super({

@@ -1,16 +0,17 @@

export * from './buffered-transform.js';
export * from './buffered.js';
export * from './chunk.js';
export * from './decode-utf8.js';
export * from './duplex.js';
export * from './gather-string.js';
export * from './inspect.js';
export * from './pipe-from.js';
export * from './push-readable.js';
export * from './split-string.js';
export * from './stream.js';
export * from './struct-deserialize.js';
export * from './struct-serialize.js';
export * from './wrap-readable.js';
export * from './wrap-writable.js';
export * from "./buffered-transform.js";
export * from "./buffered.js";
export * from "./consumable.js";
export * from "./decode-utf8.js";
export * from "./distribution.js";
export * from "./duplex.js";
export * from "./gather-string.js";
export * from "./inspect.js";
export * from "./pipe-from.js";
export * from "./push-readable.js";
export * from "./split-string.js";
export * from "./stream.js";
export * from "./struct-deserialize.js";
export * from "./struct-serialize.js";
export * from "./wrap-readable.js";
export * from "./wrap-writable.js";
//# sourceMappingURL=index.d.ts.map

@@ -1,16 +0,17 @@

export * from './buffered-transform.js';
export * from './buffered.js';
export * from './chunk.js';
export * from './decode-utf8.js';
export * from './duplex.js';
export * from './gather-string.js';
export * from './inspect.js';
export * from './pipe-from.js';
export * from './push-readable.js';
export * from './split-string.js';
export * from './stream.js';
export * from './struct-deserialize.js';
export * from './struct-serialize.js';
export * from './wrap-readable.js';
export * from './wrap-writable.js';
export * from "./buffered-transform.js";
export * from "./buffered.js";
export * from "./consumable.js";
export * from "./decode-utf8.js";
export * from "./distribution.js";
export * from "./duplex.js";
export * from "./gather-string.js";
export * from "./inspect.js";
export * from "./pipe-from.js";
export * from "./push-readable.js";
export * from "./split-string.js";
export * from "./stream.js";
export * from "./struct-deserialize.js";
export * from "./struct-serialize.js";
export * from "./wrap-readable.js";
export * from "./wrap-writable.js";
//# sourceMappingURL=index.js.map

@@ -0,0 +0,0 @@ import { TransformStream } from "./stream.js";

@@ -8,3 +8,3 @@ import { TransformStream } from "./stream.js";

controller.enqueue(chunk);
}
},
});

@@ -11,0 +11,0 @@ }

@@ -1,2 +0,3 @@

import { WritableStream, type ReadableWritablePair } from "./stream.js";
import type { ReadableWritablePair } from "./stream.js";
import { WritableStream } from "./stream.js";
/**

@@ -3,0 +4,0 @@ * Pipe `pair.readable` to `writable`, then returns `pair.writable`.

@@ -13,7 +13,5 @@ import { WritableStream } from "./stream.js";

const writer = pair.writable.getWriter();
const pipe = pair.readable
.pipeTo(writable);
const pipe = pair.readable.pipeTo(writable);
return new WritableStream({
async write(chunk) {
await writer.ready;
await writer.write(chunk);

@@ -24,5 +22,5 @@ },

await pipe;
}
},
});
}
//# sourceMappingURL=pipe-from.js.map

@@ -1,2 +0,3 @@

import { ReadableStream, type AbortSignal, type QueuingStrategy } from "./stream.js";
import type { AbortSignal, QueuingStrategy } from "./stream.js";
import { ReadableStream } from "./stream.js";
export interface PushReadableStreamController<T> {

@@ -3,0 +4,0 @@ abortSignal: AbortSignal;

import { PromiseResolver } from "@yume-chan/async";
import { AbortController, ReadableStream, } from "./stream.js";
import { AbortController, ReadableStream } from "./stream.js";
export class PushReadableStream extends ReadableStream {

@@ -4,0 +4,0 @@ /**

@@ -0,0 +0,0 @@ import { TransformStream } from "./stream.js";

@@ -21,3 +21,3 @@ import { TransformStream } from "./stream.js";

}
}
},
});

@@ -24,0 +24,0 @@ }

@@ -1,2 +0,3 @@

import { ReadableStream as ReadableStreamPolyfill, TransformStream as TransformStreamPolyfill, WritableStream as WritableStreamPolyfill, type AbortSignal } from "web-streams-polyfill";
import type { AbortSignal } from "web-streams-polyfill";
import { ReadableStream as ReadableStreamPolyfill, TransformStream as TransformStreamPolyfill, WritableStream as WritableStreamPolyfill } from "web-streams-polyfill";
export * from "web-streams-polyfill";

@@ -3,0 +4,0 @@ /** A controller object that allows you to abort one or more DOM requests as and when desired. */

@@ -0,0 +0,0 @@ import { ReadableStream as ReadableStreamPolyfill, TransformStream as TransformStreamPolyfill, WritableStream as WritableStreamPolyfill, } from "web-streams-polyfill";

import type Struct from "@yume-chan/struct";
import { type StructValueType } from "@yume-chan/struct";
import type { StructValueType } from "@yume-chan/struct";
import { BufferedTransformStream } from "./buffered-transform.js";

@@ -4,0 +4,0 @@ export declare class StructDeserializeStream<T extends Struct<any, any, any, any>> extends BufferedTransformStream<StructValueType<T>> {

@@ -0,0 +0,0 @@ import { BufferedTransformStream } from "./buffered-transform.js";

@@ -0,0 +0,0 @@ import type Struct from "@yume-chan/struct";

@@ -0,0 +0,0 @@ import { TransformStream } from "./stream.js";

@@ -1,2 +0,2 @@

import { ReadableStream, WritableStream, type ReadableWritablePair } from "./stream.js";
import { ReadableStream, file, type ReadableWritablePair } from "./stream.js";
export declare const PRESSURE_WARNINGS: Map<string, number[]>;

@@ -7,3 +7,3 @@ export declare class PressureSensor<R> implements ReadableWritablePair<R, R> {

private _writable;
get writable(): WritableStream<R>;
get writable(): file<R>;
private _name;

@@ -17,2 +17,2 @@ private _ended;

}
//# sourceMappingURL=trace.d.ts.map
//# sourceMappingURL=trace.d.ts.map

@@ -1,3 +0,4 @@

import { type ValueOrPromise } from "@yume-chan/struct";
import { ReadableStream, type ReadableStreamDefaultController } from "./stream.js";
import type { ValueOrPromise } from "@yume-chan/struct";
import type { ReadableStreamDefaultController } from "./stream.js";
import { ReadableStream } from "./stream.js";
export type WrapReadableStreamStart<T> = (controller: ReadableStreamDefaultController<T>) => ValueOrPromise<ReadableStream<T>>;

@@ -4,0 +5,0 @@ export interface ReadableStreamWrapper<T> {

@@ -1,2 +0,2 @@

import { ReadableStream, } from "./stream.js";
import { ReadableStream } from "./stream.js";
function getWrappedReadableStream(wrapper, controller) {

@@ -3,0 +3,0 @@ if ("start" in wrapper) {

@@ -1,2 +0,3 @@

import { type ValueOrPromise } from "@yume-chan/struct";
import type { ValueOrPromise } from "@yume-chan/struct";
import type { TransformStream } from "./stream.js";
import { WritableStream } from "./stream.js";

@@ -12,3 +13,4 @@ export type WrapWritableStreamStart<T> = () => ValueOrPromise<WritableStream<T>>;

constructor(wrapper: WritableStream<T> | WrapWritableStreamStart<T> | WritableStreamWrapper<T>);
bePipedThroughFrom<U>(transformer: TransformStream<U, T>): WrapWritableStream<U>;
}
//# sourceMappingURL=wrap-writable.d.ts.map

@@ -30,4 +30,2 @@ import { WritableStream } from "./stream.js";

write: async (chunk) => {
// Maintain back pressure
await this.writer.ready;
await this.writer.write(chunk);

@@ -53,3 +51,15 @@ },

}
bePipedThroughFrom(transformer) {
let promise;
return new WrapWritableStream({
start: () => {
promise = transformer.readable.pipeTo(this);
return transformer.writable;
},
async close() {
await promise;
},
});
}
}
//# sourceMappingURL=wrap-writable.js.map
{
"name": "@yume-chan/stream-extra",
"version": "0.0.18",
"version": "0.0.19",
"description": "Extensions to Web Streams API",

@@ -29,3 +29,3 @@ "keywords": [

"@yume-chan/async": "^2.2.0",
"@yume-chan/struct": "^0.0.18",
"@yume-chan/struct": "^0.0.19",
"tslib": "^2.4.1",

@@ -35,8 +35,9 @@ "web-streams-polyfill": "^4.0.0-beta.3"

"devDependencies": {
"@jest/globals": "^29.3.1",
"@jest/globals": "^29.5.0",
"@yume-chan/eslint-config": "^1.0.0",
"@yume-chan/tsconfig": "^1.0.0",
"cross-env": "^7.0.3",
"eslint": "^8.31.0",
"jest": "^29.3.1",
"eslint": "^8.36.0",
"jest": "^29.5.0",
"prettier": "^2.8.4",
"ts-jest": "^29.0.4",

@@ -49,4 +50,4 @@ "typescript": "^4.9.4"

"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
"lint": "eslint src/**/*.ts --fix"
"lint": "eslint src/**/*.ts --fix && prettier src/**/*.ts --write --tab-width 4"
}
}

@@ -43,2 +43,2 @@ # @yume-chan/stream-extra

It's not a Web Stream API `ReadableStream`, because `ReadableStream` doesn't allow hinting the desired read size (except using BYOB readable, but causes extra allocations for small reads).
It's not a Web Streams API `ReadableStream`, because `ReadableStream` doesn't allow hinting the desired read size (except using BYOB readable, but causes extra allocations for small reads).

@@ -1,2 +0,2 @@

import { type ValueOrPromise } from "@yume-chan/struct";
import type { ValueOrPromise } from "@yume-chan/struct";

@@ -7,11 +7,6 @@ import {

} from "./buffered.js";
import {
PushReadableStream,
type PushReadableStreamController,
} from "./push-readable.js";
import {
ReadableStream,
WritableStream,
type ReadableWritablePair,
} from "./stream.js";
import type { PushReadableStreamController } from "./push-readable.js";
import { PushReadableStream } from "./push-readable.js";
import type { ReadableWritablePair } from "./stream.js";
import { ReadableStream, WritableStream } from "./stream.js";

@@ -18,0 +13,0 @@ // TODO: BufferedTransformStream: find better implementation

import { PushReadableStream } from "./push-readable.js";
import {
type ReadableStream,
type ReadableStreamDefaultReader,
} from "./stream.js";
import type { ReadableStream, ReadableStreamDefaultReader } from "./stream.js";

@@ -21,4 +18,8 @@ export class BufferedReadableStreamEndedError extends Error {

private _position = 0;
public get position() {
return this._position;
}
protected readonly stream: ReadableStream<Uint8Array>;
protected readonly reader: ReadableStreamDefaultReader<Uint8Array>;

@@ -36,2 +37,3 @@

}
this._position += value.byteLength;
return value;

@@ -38,0 +40,0 @@ }

import { PromiseResolver } from "@yume-chan/async";
import { type ValueOrPromise } from "@yume-chan/struct";
import type { ValueOrPromise } from "@yume-chan/struct";
import {
WritableStream,
type ReadableStream,
type ReadableStreamDefaultController,
type WritableStreamDefaultWriter,
import type {
ReadableStream,
ReadableStreamDefaultController,
WritableStreamDefaultWriter,
} from "./stream.js";
import { WritableStream } from "./stream.js";
import { WrapReadableStream } from "./wrap-readable.js";
const NOOP = () => {
// no-op
};
export interface DuplexStreamFactoryOptions {

@@ -71,3 +75,3 @@ /**

cancel: async () => {
// cancel means the local peer closes the connection first.
// cancel means the local peer wants to close the connection.
await this.close();

@@ -90,3 +94,2 @@ },

write: async (chunk) => {
await writer.ready;
await writer.write(chunk);

@@ -99,5 +102,3 @@ },

close: async () => {
await writer.close().catch((e) => {
void e;
});
await writer.close().catch(NOOP);
await this.close();

@@ -121,5 +122,3 @@ },

for (const writer of this.writers) {
await writer.close().catch((e) => {
void e;
});
await writer.close().catch(NOOP);
}

@@ -135,4 +134,4 @@ }

controller.close();
} catch (e) {
void e;
} catch {
// ignore
}

@@ -139,0 +138,0 @@ }

import { WritableStream } from "./stream.js";
export class GatherStringStream extends WritableStream<string>{
export class GatherStringStream extends WritableStream<string> {
// PERF: rope (concat strings) is faster than `[].join('')`
private _result = '';
public get result() { return this._result; }
private _result = "";
public get result() {
return this._result;
}

@@ -8,0 +10,0 @@ public constructor() {

@@ -1,15 +0,16 @@

export * from './buffered-transform.js';
export * from './buffered.js';
export * from './chunk.js';
export * from './decode-utf8.js';
export * from './duplex.js';
export * from './gather-string.js';
export * from './inspect.js';
export * from './pipe-from.js';
export * from './push-readable.js';
export * from './split-string.js';
export * from './stream.js';
export * from './struct-deserialize.js';
export * from './struct-serialize.js';
export * from './wrap-readable.js';
export * from './wrap-writable.js';
export * from "./buffered-transform.js";
export * from "./buffered.js";
export * from "./consumable.js";
export * from "./decode-utf8.js";
export * from "./distribution.js";
export * from "./duplex.js";
export * from "./gather-string.js";
export * from "./inspect.js";
export * from "./pipe-from.js";
export * from "./push-readable.js";
export * from "./split-string.js";
export * from "./stream.js";
export * from "./struct-deserialize.js";
export * from "./struct-serialize.js";
export * from "./wrap-readable.js";
export * from "./wrap-writable.js";

@@ -9,5 +9,5 @@ import { TransformStream } from "./stream.js";

controller.enqueue(chunk);
}
},
});
}
}

@@ -1,2 +0,3 @@

import { WritableStream, type ReadableWritablePair } from "./stream.js";
import type { ReadableWritablePair } from "./stream.js";
import { WritableStream } from "./stream.js";

@@ -12,9 +13,10 @@ /**

*/
export function pipeFrom<W, T>(writable: WritableStream<W>, pair: ReadableWritablePair<W, T>) {
export function pipeFrom<W, T>(
writable: WritableStream<W>,
pair: ReadableWritablePair<W, T>
) {
const writer = pair.writable.getWriter();
const pipe = pair.readable
.pipeTo(writable);
const pipe = pair.readable.pipeTo(writable);
return new WritableStream<T>({
async write(chunk) {
await writer.ready;
await writer.write(chunk);

@@ -25,4 +27,4 @@ },

await pipe;
}
},
});
}
import { PromiseResolver } from "@yume-chan/async";
import {
AbortController,
ReadableStream,
type AbortSignal,
type QueuingStrategy,
} from "./stream.js";
import type { AbortSignal, QueuingStrategy } from "./stream.js";
import { AbortController, ReadableStream } from "./stream.js";

@@ -37,3 +33,3 @@ export interface PushReadableStreamController<T> {

let waterMarkLow: PromiseResolver<void> | undefined;
const canceled: AbortController = new AbortController();
const canceled = new AbortController();

@@ -40,0 +36,0 @@ super(

import { TransformStream } from "./stream.js";
function* split(input: string, separator: string): Generator<string, void, void> {
function* split(
input: string,
separator: string
): Generator<string, void, void> {
let start = 0;

@@ -26,5 +29,5 @@

}
}
},
});
}
}

@@ -0,1 +1,2 @@

import type { AbortSignal } from "web-streams-polyfill";
import {

@@ -5,3 +6,2 @@ ReadableStream as ReadableStreamPolyfill,

WritableStream as WritableStreamPolyfill,
type AbortSignal,
} from "web-streams-polyfill";

@@ -8,0 +8,0 @@ export * from "web-streams-polyfill";

import type Struct from "@yume-chan/struct";
import { type StructValueType } from "@yume-chan/struct";
import type { StructValueType } from "@yume-chan/struct";

@@ -4,0 +4,0 @@ import { BufferedTransformStream } from "./buffered-transform.js";

@@ -1,8 +0,8 @@

import { type ValueOrPromise } from "@yume-chan/struct";
import type { ValueOrPromise } from "@yume-chan/struct";
import {
ReadableStream,
type ReadableStreamDefaultController,
type ReadableStreamDefaultReader,
import type {
ReadableStreamDefaultController,
ReadableStreamDefaultReader,
} from "./stream.js";
import { ReadableStream } from "./stream.js";

@@ -9,0 +9,0 @@ export type WrapReadableStreamStart<T> = (

@@ -1,4 +0,5 @@

import { type ValueOrPromise } from "@yume-chan/struct";
import type { ValueOrPromise } from "@yume-chan/struct";
import { WritableStream, type WritableStreamDefaultWriter } from "./stream.js";
import type { TransformStream, WritableStreamDefaultWriter } from "./stream.js";
import { WritableStream } from "./stream.js";

@@ -54,4 +55,2 @@ export type WrapWritableStreamStart<T> = () => ValueOrPromise<

write: async (chunk) => {
// Maintain back pressure
await this.writer.ready;
await this.writer.write(chunk);

@@ -77,2 +76,15 @@ },

}
public bePipedThroughFrom<U>(transformer: TransformStream<U, T>) {
let promise: Promise<void>;
return new WrapWritableStream<U>({
start: () => {
promise = transformer.readable.pipeTo(this);
return transformer.writable;
},
async close() {
await promise;
},
});
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc