get-stream
Advanced tools
Comparing version 9.0.0 to 9.0.1
{ | ||
"name": "get-stream", | ||
"version": "9.0.0", | ||
"version": "9.0.1", | ||
"description": "Get a stream as a string, Buffer, ArrayBuffer or array", | ||
@@ -48,3 +48,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@sec-ant/readable-stream": "^0.3.2", | ||
"@sec-ant/readable-stream": "^0.4.1", | ||
"is-stream": "^4.0.1" | ||
@@ -54,3 +54,3 @@ }, | ||
"@types/node": "^20.8.9", | ||
"ava": "^5.3.1", | ||
"ava": "^6.1.2", | ||
"onetime": "^7.0.0", | ||
@@ -60,4 +60,4 @@ "precise-now": "^3.0.0", | ||
"tsd": "^0.29.0", | ||
"xo": "^0.56.0" | ||
"xo": "^0.58.0" | ||
} | ||
} |
import {getStreamContents} from './contents.js'; | ||
import {noop, throwObjectStream, getLengthProp} from './utils.js'; | ||
import {noop, throwObjectStream, getLengthProperty} from './utils.js'; | ||
@@ -79,3 +79,3 @@ export async function getStreamAsArrayBuffer(stream, options) { | ||
}, | ||
getSize: getLengthProp, | ||
getSize: getLengthProperty, | ||
truncateChunk: truncateArrayBufferChunk, | ||
@@ -82,0 +82,0 @@ addChunk: addArrayBufferChunk, |
import {getStreamContents} from './contents.js'; | ||
import {identity, noop, getContentsProp} from './utils.js'; | ||
import {identity, noop, getContentsProperty} from './utils.js'; | ||
@@ -31,3 +31,3 @@ export async function getStreamAsArray(stream, options) { | ||
getFinalChunk: noop, | ||
finalize: getContentsProp, | ||
finalize: getContentsProperty, | ||
}; |
@@ -19,3 +19,2 @@ import {getStreamAsArrayBuffer} from './array-buffer.js'; | ||
// eslint-disable-next-line n/prefer-global/buffer | ||
const arrayBufferToNodeBuffer = arrayBuffer => globalThis.Buffer.from(arrayBuffer); |
@@ -13,6 +13,21 @@ import {getAsyncIterable} from './stream.js'; | ||
const convertedChunk = convertChunk[chunkType](chunk, state); | ||
appendChunk({convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer}); | ||
appendChunk({ | ||
convertedChunk, | ||
state, | ||
getSize, | ||
truncateChunk, | ||
addChunk, | ||
maxBuffer, | ||
}); | ||
} | ||
appendFinalChunk({state, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer}); | ||
appendFinalChunk({ | ||
state, | ||
convertChunk, | ||
getSize, | ||
truncateChunk, | ||
addChunk, | ||
getFinalChunk, | ||
maxBuffer, | ||
}); | ||
return finalize(state); | ||
@@ -29,3 +44,10 @@ } catch (error) { | ||
if (convertedChunk !== undefined) { | ||
appendChunk({convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer}); | ||
appendChunk({ | ||
convertedChunk, | ||
state, | ||
getSize, | ||
truncateChunk, | ||
addChunk, | ||
maxBuffer, | ||
}); | ||
} | ||
@@ -68,3 +90,2 @@ }; | ||
// eslint-disable-next-line n/prefer-global/buffer | ||
if (globalThis.Buffer?.isBuffer(chunk)) { | ||
@@ -71,0 +92,0 @@ return 'buffer'; |
@@ -9,2 +9,3 @@ import {type Readable} from 'node:stream'; | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
type TextStreamItem = string | Buffer | ArrayBuffer | ArrayBufferView; | ||
@@ -90,2 +91,3 @@ export type AnyStream<SteamItem = TextStreamItem> = Readable | ReadableStream<SteamItem> | AsyncIterable<SteamItem>; | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
export function getStreamAsBuffer(stream: AnyStream, options?: Options): Promise<Buffer>; | ||
@@ -92,0 +94,0 @@ |
import {isReadableStream} from 'is-stream'; | ||
import {ponyfill} from './web-stream.js'; | ||
import {asyncIterator} from '@sec-ant/readable-stream/ponyfill'; | ||
@@ -15,3 +15,3 @@ export const getAsyncIterable = stream => { | ||
if (toString.call(stream) === '[object ReadableStream]') { | ||
return ponyfill.asyncIterator.call(stream); | ||
return asyncIterator.call(stream); | ||
} | ||
@@ -51,3 +51,8 @@ | ||
try { | ||
await nodeImports.finished(stream, {cleanup: true, readable: true, writable: false, error: false}); | ||
await nodeImports.finished(stream, { | ||
cleanup: true, | ||
readable: true, | ||
writable: false, | ||
error: false, | ||
}); | ||
} catch (error) { | ||
@@ -54,0 +59,0 @@ state.error = error; |
import {getStreamContents} from './contents.js'; | ||
import {identity, getContentsProp, throwObjectStream, getLengthProp} from './utils.js'; | ||
import { | ||
identity, | ||
getContentsProperty, | ||
throwObjectStream, | ||
getLengthProperty, | ||
} from './utils.js'; | ||
@@ -31,7 +36,7 @@ export async function getStreamAsString(stream, options) { | ||
}, | ||
getSize: getLengthProp, | ||
getSize: getLengthProperty, | ||
truncateChunk: truncateStringChunk, | ||
addChunk: addStringChunk, | ||
getFinalChunk: getFinalStringChunk, | ||
finalize: getContentsProp, | ||
finalize: getContentsProperty, | ||
}; |
@@ -5,3 +5,3 @@ export const identity = value => value; | ||
export const getContentsProp = ({contents}) => contents; | ||
export const getContentsProperty = ({contents}) => contents; | ||
@@ -12,2 +12,2 @@ export const throwObjectStream = chunk => { | ||
export const getLengthProp = convertedChunk => convertedChunk.length; | ||
export const getLengthProperty = convertedChunk => convertedChunk.length; |
417
28353
13
+ Added@sec-ant/readable-stream@0.4.1(transitive)
- Removed@sec-ant/readable-stream@0.3.2(transitive)