Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stardazed/streams

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stardazed/streams - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

8

CHANGELOG.md
# @stardazed/streams changelog
## 3.0.0
_2019-01-16_
* BREAKING: now uses the built-in TypeScript types and no longer exports own types. Now requires TS 3.2 or newer or your
own set of types, but using new TS is highly recommended.
* Supports the AbortSignal `signal` field in the PipeOptions for ReadableStream's pipeTo and pipeThrough methods to manually
abort pipe operations.
* Incorporate changes to streams spec up to 2019-01-16
## 2.0.0

@@ -4,0 +12,0 @@ _2018-10-15_

153

dist/sd-streams.d.ts
/**
* @stardazed/streams - implementation of the web streams standard
* Part of Stardazed
* (c) 2018 by Arthur Langereis - @zenmumbler
* (c) 2018-Present by Arthur Langereis - @zenmumbler
* https://github.com/stardazed/sd-streams
*/
// ---- Common
export interface StreamStrategy {
size?(chunk?: any): number;
highWaterMark?: number;
// extend global PipeOptions interface with signal
declare global {
interface PipeOptions {
signal?: AbortSignal;
}
}
// ---- WritableStream
// ---- Stream Types
export interface WritableStreamDefaultController {
error(e?: any): void;
}
export declare const ReadableStream: {
prototype: ReadableStream;
new(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number, size?: undefined }): ReadableStream<Uint8Array>;
new<R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;
};
export interface WritableStreamDefaultWriter<InputType> {
abort(reason: any): Promise<void>;
close(): Promise<void>;
releaseLock(): void;
write(chunk: InputType): Promise<void>;
export declare const WritableStream: {
prototype: WritableStream;
new<W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStream<W>;
};
readonly closed: Promise<void>;
readonly desiredSize: number | null;
readonly ready: Promise<void>;
}
export declare const TransformStream: {
prototype: TransformStream;
new<I = any, O = any>(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>): TransformStream<I, O>;
};
export interface WritableStreamSink<InputType> {
start?(controller: WritableStreamDefaultController): void | Promise<void>;
write?(chunk: InputType, controller: WritableStreamDefaultController): void | Promise<void>;
close?(): void | Promise<void>;
abort?(reason?: any): void;
type?: undefined; // unused, for future revisions
}
export declare class WritableStream<InputType> {
constructor(underlyingSink?: WritableStreamSink<InputType>, strategy?: StreamStrategy);
abort(reason?: any): Promise<void>;
getWriter(): WritableStreamDefaultWriter<InputType>;
readonly locked: boolean;
}
// ---- ReadableStream
export interface ReadableStreamController {
close(): void;
error(e?: any): void;
readonly desiredSize: number | null;
}
export interface ReadableStreamDefaultController<OutputType> extends ReadableStreamController {
enqueue(chunk: OutputType): void;
}
export interface ReadableByteStreamController extends ReadableStreamController {
enqueue(chunk: ArrayBufferView): void;
readonly byobRequest: ReadableStreamBYOBRequest | undefined;
}
export interface ReadableStreamBYOBRequest {
respond(bytesWritten: number): void;
respondWithNewView(view: ArrayBufferView): void;
readonly view: ArrayBufferView;
}
export interface ReadableStreamReader {
cancel(reason: any): Promise<void>;
releaseLock(): void;
readonly closed: Promise<void>;
}
export interface ReadableStreamDefaultReader<OutputType> extends ReadableStreamReader {
read(): Promise<IteratorResult<OutputType>>;
}
export interface ReadableStreamBYOBReader extends ReadableStreamReader {
read(view: ArrayBufferView): Promise<IteratorResult<ArrayBufferView>>;
}
interface ReadableStreamSource<OutputType, Controller extends ReadableStreamController = ReadableStreamDefaultController<OutputType>> {
start?(controller: Controller): void | Promise<void>;
pull?(controller: Controller): void | Promise<void>;
cancel?(reason?: any): void;
type?: "bytes" | undefined;
autoAllocateChunkSize?: number; // only for "bytes" type sources
}
export interface PipeToOptions {
preventClose?: boolean;
preventAbort?: boolean;
preventCancel?: boolean;
}
export interface StreamTransform<InputType, OutputType> {
readable: ReadableStream<OutputType>;
writable: WritableStream<InputType>;
}
export declare class ReadableStream<OutputType> {
constructor(source?: ReadableStreamSource<OutputType>, strategy?: StreamStrategy);
cancel(reason?: any): Promise<void>;
getReader(): ReadableStreamDefaultReader<OutputType>;
getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
tee(): ReadableStream<OutputType>[];
pipeThrough<ResultType>(transform: StreamTransform<OutputType, ResultType>, options?: PipeToOptions): ReadableStream<ResultType>;
pipeTo(dest: WritableStream<OutputType>, options?: PipeToOptions): Promise<void>;
readonly locked: boolean;
}
// ---- TransformStream
export interface TransformStreamDefaultController<OutputType> {
enqueue(chunk: OutputType): void;
error(reason: any): void;
terminate(): void;
readonly desiredSize: number | null;
}
export interface Transformer<InputType, OutputType> {
start?(controller: TransformStreamDefaultController<OutputType>): void | Promise<void>;
transform?(chunk: InputType, controller: TransformStreamDefaultController<OutputType>): void | Promise<void>;
flush?(controller: TransformStreamDefaultController<OutputType>): void | Promise<void>;
readableType?: undefined; // for future spec changes
writableType?: undefined; // for future spec changes
}
export declare class TransformStream<InputType, OutputType> {
constructor(transformer?: Transformer<InputType, OutputType>, writableStrategy?: StreamStrategy, readableStrategy?: StreamStrategy);
readonly readable: ReadableStream<OutputType>;
readonly writable: WritableStream<InputType>;
}
// ---- Built-in Strategies

@@ -159,3 +47,2 @@

// ---- Internal helpers for other standards

@@ -162,0 +49,0 @@

{
"name": "@stardazed/streams",
"description": "Web Streams implementation",
"version": "2.0.0",
"version": "3.0.0",
"author": {

@@ -26,6 +26,7 @@ "name": "Arthur Langereis"

"devDependencies": {
"rollup": "^0.66.2",
"rollup-plugin-typescript": "^0.8.1",
"typescript": "^3.1.1"
"rollup": "^1.1.0",
"rollup-plugin-typescript": "^1.0.0",
"tslib": "^1.9.3",
"typescript": "^3.2.2"
}
}

@@ -10,34 +10,2 @@ @stardazed/streams

Compliance
-----------
This implementation passes all tests (as specified by July 2018) in the
[web platform tests](https://github.com/web-platform-tests/wpt/tree/master/streams)
except for the detached buffer tests as explained below.
This is a good thing, but a number of tests in the suite are aimed mainly at browser engine
internals or ordering of instructions strictly to the letter of the spec.
This implementation may at any point deviate from certain spec tests for legibility or
optimization purposes, but only if it's deemed worthwhile. (Actual browser implementations
already do this as well.)
Limitations
-----------
Although the full streams API is implemented, this library's code lives in the client space
and cannot directly be used with other built-in APIs. This includes calling `getReader` on
the `body` of a `fetch` call, which may either not be implemented at all or return a browser
internal `ReadableStream`. Due to implementation details of streams, you cannot mix and
match the types in this implementation with those provided by the browser.
👉 The [streams fetch adapter](https://www.npmjs.com/package/@stardazed/streams-fetch-adapter) package
can be used to create modified versions of `fetch` and `Response` to work with this or
any other `ReadableStream` implementation.
👉 The [Stardazed streams polyfill](https://www.npmjs.com/package/@stardazed/streams-polyfill)
package provides a full replacement for streams, `fetch` and `Response` as a global polyfill.
Use this if you just want a drop-in, make-it-work version of Stardazed streams.
In addition, while the BYOB variant of `ReadableStream` is implemented, buffers are copied
and not transferred as no browser has implemented detached buffers yet, let alone exposed
them to client-level code.
Installation

@@ -74,5 +42,37 @@ ------------

Compliance
-----------
This implementation passes all tests (as specified by January 2019) in the
[web platform tests](https://github.com/web-platform-tests/wpt/tree/master/streams)
except for the detached buffer tests as explained below and a few internal name check tests.
This is a good thing, but a number of tests in the suite are aimed mainly at browser engine
internals or ordering of instructions strictly to the letter of the spec.
This implementation may at any point deviate from certain spec tests for legibility or
optimization purposes, but only if it's deemed worthwhile. (Actual browser implementations
already do this as well.)
Limitations
-----------
Although the full streams API is implemented, this library's code lives in the client space
and cannot directly be used with other built-in APIs. This includes calling `getReader` on
the `body` of a `fetch` call, which may either not be implemented at all or return a browser
internal `ReadableStream`. Due to implementation details of streams, you cannot mix and
match the types in this implementation with those provided by the browser.
👉 The [streams fetch adapter](https://www.npmjs.com/package/@stardazed/streams-fetch-adapter) package
can be used to create modified versions of `fetch` and `Response` to work with this or
any other `ReadableStream` implementation.
👉 The [Stardazed streams polyfill](https://www.npmjs.com/package/@stardazed/streams-polyfill)
package provides a full replacement for streams, `fetch` and `Response` as a global polyfill.
Use this if you just want a drop-in, make-it-work version of Stardazed streams.
In addition, while the BYOB variant of `ReadableStream` is implemented, buffers are copied
and not transferred as no browser has implemented detached buffers yet, let alone exposed
them to client-level code.
Copyright
---------
© 2018 by Arthur Langereis - [@zenmumbler](https://twitter.com/zenmumbler)
© 2018-Present by Arthur Langereis - [@zenmumbler](https://twitter.com/zenmumbler)

@@ -79,0 +79,0 @@ License

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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