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

get-stream

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-stream - npm Package Compare versions

Comparing version 8.0.1 to 9.0.0

source/exports.js

17

package.json
{
"name": "get-stream",
"version": "8.0.1",
"version": "9.0.0",
"description": "Get a stream as a string, Buffer, ArrayBuffer or array",

@@ -16,6 +16,8 @@ "license": "MIT",

"types": "./source/index.d.ts",
"browser": "./source/exports.js",
"default": "./source/index.js"
},
"sideEffects": false,
"engines": {
"node": ">=16"
"node": ">=18"
},

@@ -46,10 +48,15 @@ "scripts": {

],
"dependencies": {
"@sec-ant/readable-stream": "^0.3.2",
"is-stream": "^4.0.1"
},
"devDependencies": {
"@types/node": "^20.5.0",
"@types/node": "^20.8.9",
"ava": "^5.3.1",
"precise-now": "^2.0.0",
"onetime": "^7.0.0",
"precise-now": "^3.0.0",
"stream-json": "^1.8.0",
"tsd": "^0.28.1",
"tsd": "^0.29.0",
"xo": "^0.56.0"
}
}

@@ -7,3 +7,3 @@ # get-stream

- Works in any JavaScript environment ([Node.js](#nodejs-streams), [browsers](#web-streams), etc.).
- Works in any JavaScript environment ([Node.js](#nodejs-streams), [browsers](#browser-support), etc.).
- Supports [text streams](#getstreamstream-options), [binary streams](#getstreamasbufferstream-options) and [object streams](#getstreamasarraystream-options).

@@ -64,2 +64,4 @@ - Supports [async iterables](#async-iterables).

This works in any browser, even [the ones](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#browser_compatibility) not supporting `ReadableStream.values()` yet.
### Async iterables

@@ -147,2 +149,12 @@

## Browser support
For this module to work in browsers, a bundler must be used that either:
- Supports the [`exports.browser`](https://nodejs.org/api/packages.html#community-conditions-definitions) field in `package.json`
- Strips or ignores `node:*` imports
Most bundlers (such as [Webpack](https://webpack.js.org/guides/package-exports/#target-environment)) support either of these.
Additionally, browsers support [web streams](#web-streams) and [async iterables](#async-iterables), but not [Node.js streams](#nodejs-streams).
## Tips

@@ -149,0 +161,0 @@

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

import {getAsyncIterable} from './stream.js';
export const getStreamContents = async (stream, {init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize}, {maxBuffer = Number.POSITIVE_INFINITY} = {}) => {
if (!isAsyncIterable(stream)) {
throw new Error('The first argument must be a Readable, a ReadableStream, or an async iterable.');
}
const asyncIterable = getAsyncIterable(stream);

@@ -10,3 +10,3 @@ const state = init();

try {
for await (const chunk of stream) {
for await (const chunk of asyncIterable) {
const chunkType = getChunkType(chunk);

@@ -20,4 +20,5 @@ const convertedChunk = convertChunk[chunkType](chunk, state);

} catch (error) {
error.bufferedData = finalize(state);
throw error;
const normalizedError = typeof error === 'object' && error !== null ? error : new Error(error);
normalizedError.bufferedData = finalize(state);
throw normalizedError;
}

@@ -56,4 +57,2 @@ };

const isAsyncIterable = stream => typeof stream === 'object' && stream !== null && typeof stream[Symbol.asyncIterator] === 'function';
const getChunkType = chunk => {

@@ -60,0 +59,0 @@ const typeOfChunk = typeof chunk;

@@ -1,5 +0,13 @@

export {getStreamAsArray} from './array.js';
export {getStreamAsArrayBuffer} from './array-buffer.js';
export {getStreamAsBuffer} from './buffer.js';
export {getStreamAsString as default} from './string.js';
export {MaxBufferError} from './contents.js';
import {on} from 'node:events';
import {finished} from 'node:stream/promises';
import {nodeImports} from './stream.js';
Object.assign(nodeImports, {on, finished});
export {
default,
getStreamAsArray,
getStreamAsArrayBuffer,
getStreamAsBuffer,
MaxBufferError,
} from './exports.js';
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