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

@mattiasbuelens/web-streams-adapter

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mattiasbuelens/web-streams-adapter - npm Package Compare versions

Comparing version 0.1.0-alpha.5 to 0.1.0

65

dist/web-streams-adapter.d.ts
interface ReadableStreamLikeConstructor {
new <R extends ArrayBufferView = ArrayBufferView>(underlyingSource: UnderlyingByteSource, strategy?: {
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStreamLike<R>;
}
interface ReadableByteStreamLikeConstructor extends ReadableStreamLikeConstructor {
new (underlyingSource: UnderlyingByteSource, strategy?: {
highWaterMark?: number;
size?: undefined;
}): ReadableStreamLike<R>;
}): ReadableByteStreamLike;
new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStreamLike<R>;

@@ -11,2 +14,5 @@ }

getReader(): ReadableStreamDefaultReader<R>;
}
interface ReadableByteStreamLike extends ReadableStreamLike<ArrayBufferView> {
getReader(): ReadableStreamDefaultReader<ArrayBufferView>;
getReader({ mode }: {

@@ -16,3 +22,33 @@ mode: 'byob';

}
declare type ReadableByteStreamLike = ReadableStreamLike<ArrayBufferView>;
interface UnderlyingByteSource {
start?: UnderlyingByteSourceStartCallback;
pull?: UnderlyingByteSourcePullCallback;
cancel?: UnderlyingSourceCancelCallback;
type: 'bytes';
autoAllocateChunkSize?: number;
}
declare type UnderlyingByteSourcePullCallback = (controller: ReadableByteStreamController) => void | PromiseLike<void>;
declare type UnderlyingByteSourceStartCallback = (controller: ReadableByteStreamController) => void | PromiseLike<void>;
interface ReadableByteStreamController {
readonly byobRequest: ReadableStreamBYOBRequest | null;
readonly desiredSize: number | null;
close(): void;
enqueue(chunk: ArrayBufferView): void;
error(e?: any): void;
}
interface ReadableStreamBYOBRequest {
readonly view: ArrayBufferView | null;
respond(bytesWritten: number): void;
respondWithNewView(view: ArrayBufferView): void;
}
interface ReadableStreamBYOBReader {
readonly closed: Promise<void>;
cancel(reason?: any): Promise<void>;
read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamBYOBReadResult<T>>;
releaseLock(): void;
}
declare type ReadableStreamBYOBReadResult<T extends ArrayBufferView> = {
done: boolean;
value: T;
};
interface WritableStreamLikeConstructor {

@@ -33,11 +69,24 @@ new <W = any>(underlyingSink?: UnderlyingSink<W>, strategy?: QueuingStrategy<W>): WritableStreamLike<W>;

interface WrappingReadableSourceOptions {
type?: 'bytes';
declare type ReadableStreamWrapper = <R>(readable: ReadableStreamLike<R>, options?: {
type?: undefined;
}) => ReadableStreamLike<R>;
interface ReadableByteStreamWrapper {
(readable: ReadableByteStreamLike, options: {
type: 'bytes';
}): ReadableByteStreamLike;
<R>(readable: ReadableStreamLike<R>, options?: {
type?: undefined;
}): ReadableStreamLike<R>;
}
declare type ReadableStreamWrapper = <R>(readable: ReadableStreamLike<R>, options?: WrappingReadableSourceOptions) => ReadableStreamLike<R>;
declare type TransformStreamWrapper = <I, O>(Transform: TransformStreamLike<I, O>) => TransformStreamLike<I, O>;
declare type WritableStreamWrapper = <W>(writable: WritableStreamLike<W>) => WritableStreamLike<W>;
declare function createReadableStreamWrapper(ctor: ReadableByteStreamLikeConstructor): ReadableByteStreamWrapper;
declare function createReadableStreamWrapper(ctor: ReadableStreamLikeConstructor): ReadableStreamWrapper;
declare function createWrappingReadableSource<R = any>(readable: ReadableStreamLike<R>, { type }?: WrappingReadableSourceOptions): UnderlyingSource<R> | UnderlyingByteSource;
declare function createWrappingReadableSource(readable: ReadableByteStreamLike, options: {
type: 'bytes';
}): UnderlyingByteSource;
declare function createWrappingReadableSource<R = any>(readable: ReadableStreamLike<R>, options?: {
type?: undefined;
}): UnderlyingSource<R>;

@@ -50,2 +99,2 @@ declare function createWritableStreamWrapper(ctor: WritableStreamLikeConstructor): WritableStreamWrapper;

export { ReadableByteStreamLike, ReadableStreamLike, ReadableStreamLikeConstructor, ReadableStreamWrapper, TransformStreamLike, TransformStreamLikeConstructor, TransformStreamWrapper, WrappingReadableSourceOptions, WritableStreamLike, WritableStreamLikeConstructor, WritableStreamWrapper, createReadableStreamWrapper, createTransformStreamWrapper, createWrappingReadableSource, createWrappingTransformer, createWrappingWritableSink, createWritableStreamWrapper };
export { ReadableByteStreamController, ReadableByteStreamLike, ReadableByteStreamLikeConstructor, ReadableByteStreamWrapper, ReadableStreamBYOBReadResult, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamLike, ReadableStreamLikeConstructor, ReadableStreamWrapper, TransformStreamLike, TransformStreamLikeConstructor, TransformStreamWrapper, UnderlyingByteSource, UnderlyingByteSourcePullCallback, UnderlyingByteSourceStartCallback, WritableStreamLike, WritableStreamLikeConstructor, WritableStreamWrapper, createReadableStreamWrapper, createTransformStreamWrapper, createWrappingReadableSource, createWrappingTransformer, createWrappingWritableSink, createWritableStreamWrapper };

46

dist/web-streams-adapter.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.WebStreamsAdapter = {}));
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.WebStreamsAdapter = {}));
}(this, (function (exports) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -26,3 +26,3 @@ /* global Reflect, Promise */

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -32,2 +32,4 @@ };

function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -149,3 +151,3 @@ function __() { this.constructor = d; }

return function (readable, _a) {
var type = (_a === void 0 ? {} : _a).type;
var _b = _a === void 0 ? {} : _a, type = _b.type;
type = parseReadableType(type);

@@ -160,8 +162,14 @@ if (type === 'bytes' && !byteSourceSupported) {

}
var source = createWrappingReadableSource(readable, { type: type });
return new ctor(source);
if (type === 'bytes') {
var source = createWrappingReadableSource(readable, { type: type });
return new ctor(source);
}
else {
var source = createWrappingReadableSource(readable);
return new ctor(source);
}
};
}
function createWrappingReadableSource(readable, _a) {
var type = (_a === void 0 ? {} : _a).type;
var _b = _a === void 0 ? {} : _a, type = _b.type;
assert(isReadableStream(readable));

@@ -322,3 +330,3 @@ assert(readable.locked === false);

},
enumerable: true,
enumerable: false,
configurable: true

@@ -339,3 +347,3 @@ });

var byobRequest = this._readableStreamController.byobRequest;
if (byobRequest !== undefined) {
if (byobRequest) {
return this._pullWithByobRequest(byobRequest);

@@ -355,3 +363,3 @@ }

.then(function (result) {
var controller = _this._readableStreamController;
_this._readableStreamController;
if (result.done) {

@@ -358,0 +366,0 @@ _this._tryClose();

{
"name": "@mattiasbuelens/web-streams-adapter",
"version": "0.1.0-alpha.5",
"version": "0.1.0",
"description": "Adapters for converting between different implementations of WHATWG Streams",

@@ -11,2 +11,5 @@ "main": "dist/web-streams-adapter",

],
"engines": {
"node": ">= 12"
},
"scripts": {

@@ -27,17 +30,18 @@ "build": "rollup -c",

"devDependencies": {
"@rollup/plugin-typescript": "^4.1.1",
"@rollup/plugin-typescript": "^8.2.1",
"@types/micromatch": "^4.0.1",
"@types/node": "^10.17.21",
"@types/resolve": "^1.14.0",
"micromatch": "^4.0.2",
"resolve": "^1.17.0",
"rollup": "^2.7.2",
"rollup-plugin-cleanup": "^3.1.1",
"rollup-plugin-dts": "^1.4.0",
"ts-node": "^8.9.0",
"tslib": "^1.11.1",
"typescript": "^3.8.3",
"web-streams-polyfill": "^2.1.1",
"wpt-runner": "^2.8.0"
"@types/node": "^14.14.44",
"@types/resolve": "^1.20.0",
"@ungap/promise-all-settled": "^1.1.2",
"micromatch": "^4.0.4",
"resolve": "^1.20.0",
"rollup": "^2.47.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-dts": "^3.0.1",
"ts-node": "^9.1.1",
"tslib": "^2.2.0",
"typescript": "^4.2.4",
"web-streams-polyfill": "^3.0.3",
"wpt-runner": "^3.2.1"
}
}

@@ -16,8 +16,8 @@ # web-streams-adapter

most of them are not yet fully up-to-date with the latest specification:
* Chrome 59 supports `ReadableStream` and `WritableStream`,
and `TransformStream` [will arrive in Chrome 67][ts-chrome-status].
Readable byte streams are [not yet supported][byte-stream-chrome-bug].
* Firefox 57 supports `ReadableStream`, but only behind an experimental flag.
* Edge 16 supports `ReadableStream`, but does not yet support developer-created streams using `new ReadableStream`.
`WritableStream` however is fully supported.
* Chrome 67 [supports][ts-chrome-status] `ReadableStream`, `WritableStream` and `TransformStream`.
Readable byte streams are [supported][byte-stream-chrome-status] as of Chrome 89.
However, async iteration is [not yet supported][async-iterator-crbug].
* Edge 89 has the same support as Chrome 89.
* Firefox 65 supports `ReadableStream`, but no readable byte streams or writable streams yet.
As such, methods like `pipeTo()` and `pipeThrough()` that take a `WritableStream` are not yet supported either.
* Safari supports `ReadableStream`, but no readable byte streams or writable streams.

@@ -31,3 +31,3 @@

and wraps it into a different readable/writable/stream with a different (more complete) implementation of your choice,
for example [`web-streams-polyfill`][creatorrr-polyfill].
for example [web-streams-polyfill].
```js

@@ -69,6 +69,7 @@ // setup

[ts-chrome-status]: https://www.chromestatus.com/feature/5466425791610880
[byte-stream-chrome-bug]: https://bugs.chromium.org/p/chromium/issues/detail?id=614302
[byte-stream-chrome-status]: https://chromestatus.com/feature/4535319661641728
[async-iterator-crbug]: https://crbug.com/929585
[caniuse]: https://www.caniuse.com/#feat=streams
[rs-compat]: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#Browser_Compatibility
[ws-compat]: https://developer.mozilla.org/en-US/docs/Web/API/WritableStream#Browser_Compatibility
[creatorrr-polyfill]: https://github.com/creatorrr/web-streams-polyfill
[web-streams-polyfill]: https://github.com/MattiasBuelens/web-streams-polyfill

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