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

@smithy/chunked-blob-reader

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/chunked-blob-reader - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

31

dist-cjs/index.js

@@ -26,25 +26,10 @@ var __defProp = Object.defineProperty;

module.exports = __toCommonJS(src_exports);
function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.addEventListener("error", reject);
fileReader.addEventListener("abort", reject);
const size = blob.size;
let totalBytesRead = 0;
function read() {
if (totalBytesRead >= size) {
resolve();
return;
}
fileReader.readAsArrayBuffer(blob.slice(totalBytesRead, Math.min(size, totalBytesRead + chunkSize)));
}
__name(read, "read");
fileReader.addEventListener("load", (event) => {
const result = event.target.result;
onChunk(new Uint8Array(result));
totalBytesRead += result.byteLength;
read();
});
read();
});
async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
const size = blob.size;
let totalBytesRead = 0;
while (totalBytesRead < size) {
const slice = blob.slice(totalBytesRead, Math.min(size, totalBytesRead + chunkSize));
onChunk(new Uint8Array(await slice.arrayBuffer()));
totalBytesRead += slice.size;
}
}

@@ -51,0 +36,0 @@ __name(blobReader, "blobReader");

@@ -1,23 +0,9 @@

export function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.addEventListener("error", reject);
fileReader.addEventListener("abort", reject);
const size = blob.size;
let totalBytesRead = 0;
function read() {
if (totalBytesRead >= size) {
resolve();
return;
}
fileReader.readAsArrayBuffer(blob.slice(totalBytesRead, Math.min(size, totalBytesRead + chunkSize)));
}
fileReader.addEventListener("load", (event) => {
const result = event.target.result;
onChunk(new Uint8Array(result));
totalBytesRead += result.byteLength;
read();
});
read();
});
export async function blobReader(blob, onChunk, chunkSize = 1024 * 1024) {
const size = blob.size;
let totalBytesRead = 0;
while (totalBytesRead < size) {
const slice = blob.slice(totalBytesRead, Math.min(size, totalBytesRead + chunkSize));
onChunk(new Uint8Array(await slice.arrayBuffer()));
totalBytesRead += slice.size;
}
}
/**
* @internal
* Reads the blob data into the onChunk consumer.
*/
export declare function blobReader(blob: Blob, onChunk: (chunk: Uint8Array) => void, chunkSize?: number): Promise<void>;
/**
* @internal
* Reads the blob data into the onChunk consumer.
*/
export declare function blobReader(blob: Blob, onChunk: (chunk: Uint8Array) => void, chunkSize?: number): Promise<void>;
{
"name": "@smithy/chunked-blob-reader",
"version": "3.0.0",
"version": "4.0.0",
"scripts": {

@@ -9,3 +9,3 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",

"build:types": "yarn g:tsc -p tsconfig.types.json",
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
"build:types:downlevel": "rimraf dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4",
"stage-release": "rimraf ./.release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",

@@ -12,0 +12,0 @@ "clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0",

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