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

@sapphire/async-queue

Package Overview
Dependencies
Maintainers
3
Versions
831
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sapphire/async-queue - npm Package Compare versions

Comparing version 1.5.3-next.25e6d13b to 1.5.3-next.269734b3

24

dist/iife/index.global.js

@@ -7,8 +7,5 @@ var SapphireAsyncQueue = (function (exports) {

var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
// src/lib/AsyncQueueEntry.ts
// src/lib/_AsyncQueueEntry.ts
var _AsyncQueueEntry = class _AsyncQueueEntry {

@@ -29,9 +26,7 @@ constructor(queue) {

setSignal(signal) {
if (signal.aborted)
return this;
if (signal.aborted) return this;
this.signal = signal;
this.signalListener = () => {
const index = this.queue["promises"].indexOf(this);
if (index !== -1)
this.queue["promises"].splice(index, 1);
if (index !== -1) this.queue["promises"].splice(index, 1);
this.reject(new Error("Request aborted manually"));

@@ -113,4 +108,3 @@ };

this.promises.push(entry);
if (options?.signal)
entry.setSignal(options.signal);
if (options?.signal) entry.setSignal(options.signal);
return entry.promise;

@@ -122,4 +116,3 @@ }

shift() {
if (this.promises.length === 0)
return;
if (this.promises.length === 0) return;
if (this.promises.length === 1) {

@@ -137,4 +130,3 @@ this.promises.shift();

abortAll() {
if (this.queued === 0)
return;
if (this.queued === 0) return;
for (let i = 1; i < this.promises.length; ++i) {

@@ -154,3 +146,3 @@ this.promises[i].abort();

})({});
//# sourceMappingURL=out.js.map
//# sourceMappingURL=index.global.js.map
//# sourceMappingURL=index.global.js.map
{
"name": "@sapphire/async-queue",
"version": "1.5.3-next.25e6d13b",
"version": "1.5.3-next.269734b3",
"description": "Sequential asynchronous lock-based queue for promises",

@@ -29,7 +29,8 @@ "author": "@sapphire",

"docs": "typedoc-json-parser",
"build": "tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts",
"build": "yarn gen-index && tsup && yarn build:rename-cjs-index",
"build:rename-cjs-index": "tsx ../../scripts/rename-cjs-index.cts",
"prepack": "yarn build",
"bump": "cliff-jumper",
"check-update": "cliff-jumper --dry-run"
"check-update": "cliff-jumper --dry-run",
"gen-index": "tsx ../../scripts/gen-index.cts -w async-queue"
},

@@ -66,10 +67,10 @@ "repository": {

"@favware/cliff-jumper": "^4.0.2",
"@vitest/coverage-v8": "^1.6.0",
"tsup": "^8.0.2",
"tsx": "^4.11.0",
"@vitest/coverage-v8": "^2.0.3",
"tsup": "^8.2.1",
"tsx": "^4.16.2",
"typedoc": "^0.25.13",
"typedoc-json-parser": "^10.0.0",
"typescript": "^5.4.5",
"vitest": "^1.6.0"
"typescript": "~5.4.5",
"vitest": "^2.0.3"
}
}

@@ -16,5 +16,9 @@ <div align="center">

## Description
**Table of Contents**
Ever needed a queue for a set of promises? This is the package for you.
- [Features](#features)
- [Installation](#installation)
- [Usage](#usage)
- [Buy us some doughnuts](#buy-us-some-doughnuts)
- [Contributors](#contributors)

@@ -25,3 +29,3 @@ ## Features

- Bundled with esbuild so it can be used in NodeJS and browsers
- Offers CommonJS, ESM and UMD bundles
- Offers CommonJS, ESM, and UMD bundles
- Fully tested

@@ -37,2 +41,35 @@

## Usage
**Note**: While this section uses `require`, the imports match 1:1 with ESM imports. For example `const { AsyncQueue } = require('@sapphire/async-queue')` equals `import { AsyncQueue } from '@sapphire/async-queue'`.
```typescript
// Require the AsyncQueue class
const { AsyncQueue } = require('@sapphire/async-queue');
const queue = new AsyncQueue();
async function request(url, options) {
// Wait and lock the queue
await queue.wait();
try {
// Perform the operation sequentially
return await fetch(url, options);
} finally {
// Unlock the next promise in the queue
queue.shift();
}
}
request(someUrl1, someOptions1);
// Will call fetch() immediately
request(someUrl2, someOptions2);
// Will call fetch() after the first finished
request(someUrl3, someOptions3);
// Will call fetch() after the second finished
```
---

@@ -44,3 +81,3 @@

We accept donations through Open Collective, Ko-fi, PayPal, Patreon and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.
We accept donations through Open Collective, Ko-fi, PayPal, Patreon, and GitHub Sponsorships. You can use the buttons below to donate through your method of choice.

@@ -47,0 +84,0 @@ | Donate With | Address |

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 not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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