🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

sema4

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sema4 - npm Package Compare versions

Comparing version
0.0.5
to
0.0.6
+13
-5
dist/index.js

@@ -8,2 +8,5 @@ 'use strict';

// src/Deque.ts
var MIN_CAPACITY = 4;
var MAX_CAPACITY = 1073741824;
var RESIZE_MULTIPLER = 1;
function arrayMove(src, srcIndex, dst, dstIndex, len) {

@@ -26,3 +29,3 @@ for (let j = 0; j < len; ++j) {

function getCapacity(capacity) {
return pow2AtLeast(Math.min(Math.max(16, capacity), 1073741824));
return pow2AtLeast(Math.min(Math.max(MIN_CAPACITY, capacity), MAX_CAPACITY));
}

@@ -34,4 +37,4 @@ var Deque = class {

arr;
constructor(capacity) {
this._capacity = getCapacity(capacity);
constructor(initialCapacity = 4) {
this._capacity = getCapacity(initialCapacity);
this._length = 0;

@@ -77,3 +80,3 @@ this._front = 0;

if (this._capacity < size) {
this.resizeTo(getCapacity(this._capacity * 1.5 + 16));
this.resizeTo(getCapacity(this._capacity * RESIZE_MULTIPLER + MIN_CAPACITY));
}

@@ -113,3 +116,3 @@ }

} = {}) {
if (isFn(pauseFn) !== isFn(resumeFn)) {
if (isFn(pauseFn) && !isFn(resumeFn)) {
throw new Error("pauseFn and resumeFn must be both set for pausing");

@@ -178,2 +181,7 @@ }

} = {}) {
if (!Number.isInteger(rptu) || rptu < 0) {
throw new TypeError(
"The rate-limit-per-time-unit (rptu) should be an integer and greater than zero"
);
}
const sema = new Sema(uniformDistribution ? 1 : rptu);

@@ -180,0 +188,0 @@ const delay = uniformDistribution ? timeUnit / rptu : timeUnit;

@@ -6,2 +6,5 @@ import { EventEmitter } from 'events';

// src/Deque.ts
var MIN_CAPACITY = 4;
var MAX_CAPACITY = 1073741824;
var RESIZE_MULTIPLER = 1;
function arrayMove(src, srcIndex, dst, dstIndex, len) {

@@ -24,3 +27,3 @@ for (let j = 0; j < len; ++j) {

function getCapacity(capacity) {
return pow2AtLeast(Math.min(Math.max(16, capacity), 1073741824));
return pow2AtLeast(Math.min(Math.max(MIN_CAPACITY, capacity), MAX_CAPACITY));
}

@@ -32,4 +35,4 @@ var Deque = class {

arr;
constructor(capacity) {
this._capacity = getCapacity(capacity);
constructor(initialCapacity = 4) {
this._capacity = getCapacity(initialCapacity);
this._length = 0;

@@ -75,3 +78,3 @@ this._front = 0;

if (this._capacity < size) {
this.resizeTo(getCapacity(this._capacity * 1.5 + 16));
this.resizeTo(getCapacity(this._capacity * RESIZE_MULTIPLER + MIN_CAPACITY));
}

@@ -111,3 +114,3 @@ }

} = {}) {
if (isFn(pauseFn) !== isFn(resumeFn)) {
if (isFn(pauseFn) && !isFn(resumeFn)) {
throw new Error("pauseFn and resumeFn must be both set for pausing");

@@ -176,2 +179,7 @@ }

} = {}) {
if (!Number.isInteger(rptu) || rptu < 0) {
throw new TypeError(
"The rate-limit-per-time-unit (rptu) should be an integer and greater than zero"
);
}
const sema = new Sema(uniformDistribution ? 1 : rptu);

@@ -178,0 +186,0 @@ const delay = uniformDistribution ? timeUnit / rptu : timeUnit;

{
"name": "sema4",
"version": "0.0.5",
"version": "0.0.6",
"description": "Semaphore using `async` and `await`",

@@ -5,0 +5,0 @@ "keywords": [

@@ -34,3 +34,4 @@ # sema4

- **Universal** - Works in all modern browsers, [Node.js](https://nodejs.org/), and [Deno](https://deno.land/) and supports [CLI](https://www.npmjs.com/package/@gitbeaker/cli) usage.
- **Tested** - Greater than 80% test coverage.
- **Zero Dependencies** - Absolutely no dependencies, keeping the package tiny (24kb).
- **Tested** - Greater than 85% test coverage.
- **Typed** - Out of the box TypeScript declarations.

@@ -37,0 +38,0 @@