@bytescale/sdk
Advanced tools
Comparing version 3.23.1 to 3.24.0
@@ -46,2 +46,6 @@ /** | ||
/** | ||
* The base URL of the Bytescale CDN. (Excludes trailing "/".) | ||
*/ | ||
cdnUrl?: string; | ||
/** | ||
* Forces the browser to display a download prompt for the file, instead of displaying the file in the browser. | ||
@@ -48,0 +52,0 @@ * |
{ | ||
"name": "@bytescale/sdk", | ||
"version": "3.23.1", | ||
"version": "3.24.0", | ||
"description": "Bytescale JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "author": "Bytescale <hello@bytescale.com> (https://www.bytescale.com)", |
@@ -18,6 +18,17 @@ // import randomGen from "random-seed"; | ||
// Ensure the chunk size is small enough to cause enough entropy (as we pick a new character for reach chunk). | ||
const minRandomBlocks = 10; | ||
const maxChunkSize = Math.min(64 * 1024, Math.ceil(sizeInBytes / minRandomBlocks)); | ||
let producedSize = 0; | ||
let iteration = 0; | ||
return new Readable({ | ||
read(readSize) { | ||
read(requestedReadSize) { | ||
const maxRequestedReadSize = Math.min(requestedReadSize, maxChunkSize); | ||
// This ensures streams of the same size are unique, else they would have the same contents, assuming chunk size is the same. | ||
// We use 0.8-1 to prevent really small chunks, which may create inefficiencies. | ||
const randomness = randomBetween(0.8, 1); | ||
let readSize = Math.ceil(maxRequestedReadSize * randomness); | ||
let shouldEnd = false; | ||
@@ -52,2 +63,6 @@ | ||
function randomBetween(min: number, max: number): number { | ||
return Math.random() * (max - min) + min; | ||
} | ||
async function writeToDisk(reader: NodeJS.ReadableStream, path: string): Promise<void> { | ||
@@ -54,0 +69,0 @@ await new Promise((resolve, reject) => { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1015792
20952
6