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

@libp2p/utils

Package Overview
Dependencies
Maintainers
6
Versions
532
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/utils - npm Package Compare versions

Comparing version 6.0.6-58784abf7 to 6.0.6-80e798cdc

4

dist/src/errors.d.ts

@@ -12,2 +12,6 @@ import type { RateLimiterResult } from './rate-limiter.js';

}
export declare class QueueFullError extends Error {
static name: string;
constructor(message?: string);
}
//# sourceMappingURL=errors.d.ts.map

@@ -18,2 +18,9 @@ /**

}
export class QueueFullError extends Error {
static name = 'QueueFullError';
constructor(message = 'The queue was full') {
super(message);
this.name = 'QueueFullError';
}
}
//# sourceMappingURL=errors.js.map

@@ -19,2 +19,9 @@ import { TypedEventEmitter } from '@libp2p/interface';

/**
* If the queue size grows to larger than this number the promise returned
* from the add function will reject
*
* @default Infinity
*/
maxSize?: number;
/**
* The name of the metric for the queue length

@@ -33,4 +40,4 @@ */

export type JobStatus = 'queued' | 'running' | 'errored' | 'complete';
export interface RunFunction<Options = AbortOptions, ReturnType = void> {
(opts?: Options): Promise<ReturnType>;
export interface RunFunction<Options extends AbortOptions = AbortOptions, ReturnType = void> {
(options: Options): Promise<ReturnType>;
}

@@ -96,2 +103,3 @@ export interface JobMatcher<JobOptions extends AbortOptions = AbortOptions> {

concurrency: number;
maxSize: number;
queue: Array<Job<JobOptions, JobReturnType>>;

@@ -98,0 +106,0 @@ private pending;

import { AbortError, TypedEventEmitter } from '@libp2p/interface';
import { pushable } from 'it-pushable';
import { raceEvent } from 'race-event';
import { QueueFullError } from '../errors.js';
import { Job } from './job.js';

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

concurrency;
maxSize;
queue;

@@ -20,2 +22,3 @@ pending;

this.concurrency = init.concurrency ?? Number.POSITIVE_INFINITY;
this.maxSize = init.maxSize ?? Number.POSITIVE_INFINITY;
this.pending = 0;

@@ -93,2 +96,5 @@ if (init.metricName != null) {

options?.signal?.throwIfAborted();
if (this.size === this.maxSize) {
throw new QueueFullError();
}
const job = new Job(fn, options);

@@ -95,0 +101,0 @@ this.enqueue(job);

9

package.json
{
"name": "@libp2p/utils",
"version": "6.0.6-58784abf7",
"version": "6.0.6-80e798cdc",
"description": "Package to aggregate shared logic and dependencies for the libp2p ecosystem",

@@ -151,5 +151,5 @@ "license": "Apache-2.0 OR MIT",

"@chainsafe/is-ip": "^2.0.2",
"@libp2p/crypto": "5.0.4-58784abf7",
"@libp2p/interface": "2.1.2-58784abf7",
"@libp2p/logger": "5.1.0-58784abf7",
"@libp2p/crypto": "5.0.4-80e798cdc",
"@libp2p/interface": "2.1.2-80e798cdc",
"@libp2p/logger": "5.1.0-80e798cdc",
"@multiformats/multiaddr": "^12.2.3",

@@ -175,2 +175,3 @@ "@sindresorhus/fnv1a": "^3.1.0",

"devDependencies": {
"@libp2p/peer-id": "5.0.4-80e798cdc",
"@types/netmask": "^2.0.5",

@@ -177,0 +178,0 @@ "aegir": "^44.0.1",

@@ -21,1 +21,10 @@ import type { RateLimiterResult } from './rate-limiter.js'

}
export class QueueFullError extends Error {
static name = 'QueueFullError'
constructor (message: string = 'The queue was full') {
super(message)
this.name = 'QueueFullError'
}
}
import { AbortError, TypedEventEmitter } from '@libp2p/interface'
import { pushable } from 'it-pushable'
import { raceEvent } from 'race-event'
import { QueueFullError } from '../errors.js'
import { Job } from './job.js'

@@ -25,2 +26,10 @@ import type { AbortOptions, Metrics } from '@libp2p/interface'

/**
* If the queue size grows to larger than this number the promise returned
* from the add function will reject
*
* @default Infinity
*/
maxSize?: number
/**
* The name of the metric for the queue length

@@ -43,4 +52,4 @@ */

export interface RunFunction<Options = AbortOptions, ReturnType = void> {
(opts?: Options): Promise<ReturnType>
export interface RunFunction<Options extends AbortOptions = AbortOptions, ReturnType = void> {
(options: Options): Promise<ReturnType>
}

@@ -119,2 +128,3 @@

public concurrency: number
public maxSize: number
public queue: Array<Job<JobOptions, JobReturnType>>

@@ -128,2 +138,3 @@ private pending: number

this.concurrency = init.concurrency ?? Number.POSITIVE_INFINITY
this.maxSize = init.maxSize ?? Number.POSITIVE_INFINITY
this.pending = 0

@@ -219,2 +230,6 @@

if (this.size === this.maxSize) {
throw new QueueFullError()
}
const job = new Job<JobOptions, JobReturnType>(fn, options)

@@ -221,0 +236,0 @@ this.enqueue(job)

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