![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
fetch-in-chunks
Advanced tools
A utility for fetching large files in chunks with support for parallel downloads and progress tracking.
A utility for fetching large files in chunks with support for parallel downloads, progress tracking, and request abortion.
Install the package using npm:
npm install fetch-in-chunks
import fetchInChunks from 'fetch-in-chunks';
async function fetchInChunks(url, options = {})
url
(string
): The URL of the file to download.options
(object
, optional): An object containing additional options.
options.chunkSize
(number
, default: 5 * 1024 * 1024
): The size of each
chunk to download in bytes.options.maxParallelRequests
(number
, default: 1
): The number of chunks
to download in parallel.options.progressCallback
(function
, optional): A callback function that
will be called with the number of bytes downloaded and the total size of the
file.options.signal
(AbortSignal
, optional): An AbortSignal
object that can
be used to abort the download.Promise<Blob>
: A promise that resolves to a Blob
containing the downloaded
file.import fetchInChunks from 'fetch-in-chunks';
async function downloadFile() {
try {
const blob = await fetchInChunks('https://example.com/largefile.zip');
return blob;
} catch (error) {
console.error('Error fetching file:', error);
}
}
downloadFile();
import fetchInChunks from 'fetch-in-chunks';
async function downloadFileWithProgress() {
try {
const blob = await fetchInChunks('https://example.com/largefile.zip', {
progressCallback: (downloaded, total) => {
console.log(`Downloaded ${((downloaded / total) * 100).toFixed(2)}%`);
},
});
return blob;
} catch (error) {
console.error('Error fetching file:', error);
}
}
downloadFileWithProgress();
AbortController
import fetchInChunks from 'fetch-in-chunks';
async function downloadFileWithAbort() {
const controller = new AbortController();
const signal = controller.signal;
try {
const blob = await fetchInChunks('https://example.com/largefile.zip', {
signal,
});
return blob;
} catch (error) {
if (error.name === 'AbortError') {
console.log('Download aborted');
} else {
console.error('Error fetching file:', error);
}
}
}
// To abort the download at any time
controller.abort();
This project is licensed under the Apache 2.0 License. See the LICENSE
file
for details.
FAQs
A utility for fetching large files in chunks with support for parallel downloads and progress tracking.
The npm package fetch-in-chunks receives a total of 0 weekly downloads. As such, fetch-in-chunks popularity was classified as not popular.
We found that fetch-in-chunks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.