@smithy/fetch-http-handler
Advanced tools
Comparing version 3.2.9 to 4.0.0
@@ -195,15 +195,8 @@ var __defProp = Object.defineProperty; | ||
// src/stream-collector.ts | ||
var import_util_base64 = require("@smithy/util-base64"); | ||
var streamCollector = /* @__PURE__ */ __name((stream) => { | ||
var streamCollector = /* @__PURE__ */ __name(async (stream) => { | ||
if (typeof Blob === "function" && stream instanceof Blob) { | ||
return collectBlob(stream); | ||
return new Uint8Array(await stream.arrayBuffer()); | ||
} | ||
return collectStream(stream); | ||
}, "streamCollector"); | ||
async function collectBlob(blob) { | ||
const base64 = await readToBase64(blob); | ||
const arrayBuffer = (0, import_util_base64.fromBase64)(base64); | ||
return new Uint8Array(arrayBuffer); | ||
} | ||
__name(collectBlob, "collectBlob"); | ||
async function collectStream(stream) { | ||
@@ -231,20 +224,2 @@ const chunks = []; | ||
__name(collectStream, "collectStream"); | ||
function readToBase64(blob) { | ||
return new Promise((resolve, reject) => { | ||
const reader = new FileReader(); | ||
reader.onloadend = () => { | ||
if (reader.readyState !== 2) { | ||
return reject(new Error("Reader aborted too early")); | ||
} | ||
const result = reader.result ?? ""; | ||
const commaIndex = result.indexOf(","); | ||
const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length; | ||
resolve(result.substring(dataOffset)); | ||
}; | ||
reader.onabort = () => reject(new Error("Read aborted")); | ||
reader.onerror = () => reject(reader.error); | ||
reader.readAsDataURL(blob); | ||
}); | ||
} | ||
__name(readToBase64, "readToBase64"); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -251,0 +226,0 @@ |
@@ -1,13 +0,7 @@ | ||
import { fromBase64 } from "@smithy/util-base64"; | ||
export const streamCollector = (stream) => { | ||
export const streamCollector = async (stream) => { | ||
if (typeof Blob === "function" && stream instanceof Blob) { | ||
return collectBlob(stream); | ||
return new Uint8Array(await stream.arrayBuffer()); | ||
} | ||
return collectStream(stream); | ||
}; | ||
async function collectBlob(blob) { | ||
const base64 = await readToBase64(blob); | ||
const arrayBuffer = fromBase64(base64); | ||
return new Uint8Array(arrayBuffer); | ||
} | ||
async function collectStream(stream) { | ||
@@ -34,18 +28,1 @@ const chunks = []; | ||
} | ||
function readToBase64(blob) { | ||
return new Promise((resolve, reject) => { | ||
const reader = new FileReader(); | ||
reader.onloadend = () => { | ||
if (reader.readyState !== 2) { | ||
return reject(new Error("Reader aborted too early")); | ||
} | ||
const result = (reader.result ?? ""); | ||
const commaIndex = result.indexOf(","); | ||
const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length; | ||
resolve(result.substring(dataOffset)); | ||
}; | ||
reader.onabort = () => reject(new Error("Read aborted")); | ||
reader.onerror = () => reject(reader.error); | ||
reader.readAsDataURL(blob); | ||
}); | ||
} |
{ | ||
"name": "@smithy/fetch-http-handler", | ||
"version": "3.2.9", | ||
"version": "4.0.0", | ||
"description": "Provides a way to make requests", | ||
@@ -27,5 +27,5 @@ "scripts": { | ||
"dependencies": { | ||
"@smithy/protocol-http": "^4.1.4", | ||
"@smithy/querystring-builder": "^3.0.7", | ||
"@smithy/types": "^3.5.0", | ||
"@smithy/protocol-http": "^4.1.5", | ||
"@smithy/querystring-builder": "^3.0.8", | ||
"@smithy/types": "^3.6.0", | ||
"@smithy/util-base64": "^3.0.0", | ||
@@ -35,3 +35,3 @@ "tslib": "^2.6.2" | ||
"devDependencies": { | ||
"@smithy/abort-controller": "^3.1.5", | ||
"@smithy/abort-controller": "^3.1.6", | ||
"concurrently": "7.0.0", | ||
@@ -38,0 +38,0 @@ "downlevel-dts": "0.10.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32050
477
Updated@smithy/protocol-http@^4.1.5
Updated@smithy/types@^3.6.0