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

electron-dl-manager

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

electron-dl-manager - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

24

dist/cjs/ElectronDownloadManager.js

@@ -7,2 +7,21 @@ "use strict";

/**
* This is used to solve an issue where multiple downloads are started at the same time.
* For example, Promise.all([download1, download2, ...]) will start both downloads at the same
* time. This is problematic because the will-download event is not guaranteed to fire in the
* order that the downloads were started.
*
* So we use this to make sure that will-download fires in the order that the downloads were
* started by executing the downloads in a sequential fashion.
*
* For more information see:
* https://github.com/theogravity/electron-dl-manager/issues/11
*/
class DownloadQueue {
promise = Promise.resolve();
add(task) {
this.promise = this.promise.then(() => task());
return this.promise;
}
}
/**
* Enables handling downloads in Electron.

@@ -13,2 +32,3 @@ */

logger;
downloadQueue = new DownloadQueue();
constructor(params = {}) {

@@ -79,3 +99,3 @@ this.downloadData = {};

async download(params) {
return new Promise((resolve, reject) => {
return this.downloadQueue.add(() => new Promise((resolve, reject) => {
try {

@@ -102,3 +122,3 @@ if (params.saveAsFilename && params.saveDialogOptions) {

}
});
}));
}

@@ -105,0 +125,0 @@ cleanup(data) {

import { DownloadInitiator } from "./DownloadInitiator";
import { truncateUrl } from "./utils";
/**
* This is used to solve an issue where multiple downloads are started at the same time.
* For example, Promise.all([download1, download2, ...]) will start both downloads at the same
* time. This is problematic because the will-download event is not guaranteed to fire in the
* order that the downloads were started.
*
* So we use this to make sure that will-download fires in the order that the downloads were
* started by executing the downloads in a sequential fashion.
*
* For more information see:
* https://github.com/theogravity/electron-dl-manager/issues/11
*/
class DownloadQueue {
promise = Promise.resolve();
add(task) {
this.promise = this.promise.then(() => task());
return this.promise;
}
}
/**
* Enables handling downloads in Electron.

@@ -9,2 +28,3 @@ */

logger;
downloadQueue = new DownloadQueue();
constructor(params = {}) {

@@ -75,3 +95,3 @@ this.downloadData = {};

async download(params) {
return new Promise((resolve, reject) => {
return this.downloadQueue.add(() => new Promise((resolve, reject) => {
try {

@@ -98,3 +118,3 @@ if (params.saveAsFilename && params.saveDialogOptions) {

}
});
}));
}

@@ -101,0 +121,0 @@ cleanup(data) {

@@ -10,2 +10,3 @@ import type { BrowserWindow } from "electron";

protected logger: DebugLoggerFn;
private downloadQueue;
constructor(params?: DownloadManagerConstructorParams);

@@ -12,0 +13,0 @@ protected log(message: string): void;

2

package.json
{
"name": "electron-dl-manager",
"version": "3.1.1",
"version": "3.2.0",
"description": "A library for implementing file downloads in Electron with 'save as' dialog and id support.",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

@@ -28,4 +28,2 @@ # Electron File Download Manager

// Start a download
// You *must* call manager.download() with await or
// you may get unexpected behavior
const id = await manager.download({

@@ -192,4 +190,2 @@ window: browserWindowInstance,

**You must call `download()` with `await` or you may get unexpected behavior.**
```typescript

@@ -196,0 +192,0 @@ download(params: DownloadParams): Promise<string>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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