New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gamla

Package Overview
Dependencies
Maintainers
0
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gamla - npm Package Compare versions

Comparing version 85.0.0 to 86.0.0

6

esm/src/lock.d.ts

@@ -5,6 +5,2 @@ import { AsyncFunction } from "./typing.js";

export declare const rateLimit: <Function_1 extends AsyncFunction>(maxCalls: number, maxWeight: number, timeWindowMs: number, weight: (...args: Parameters<Function_1>) => number, f: Function_1) => Function_1;
export declare const semaphore: (max: number) => {
acquire: () => Promise<void>;
release: () => void;
};
export declare const throttle: <Function_1 extends AsyncFunction>(max: number) => (f: Function_1) => (...args: Parameters<Function_1>) => Promise<any>;
export declare const throttle: (max: number) => <F extends AsyncFunction>(f: F) => F;

21

esm/src/lock.js

@@ -56,3 +56,3 @@ import { sleep } from "./time.js";

};
export const semaphore = (max) => {
const semaphore = (max) => {
let counter = 0;

@@ -83,13 +83,12 @@ const waiting = [];

const { acquire, release } = semaphore(max);
return (f) => {
return async (...args) => {
await acquire();
try {
return await f(...args);
}
finally {
release();
}
};
// @ts-expect-error too complex
return (f) => async (...args) => {
await acquire();
try {
return await f(...args);
}
finally {
release();
}
};
};
{
"name": "gamla",
"version": "85.0.0",
"version": "86.0.0",
"description": "Functional programming with async and type safety",

@@ -5,0 +5,0 @@ "repository": {

@@ -5,6 +5,2 @@ import { AsyncFunction } from "./typing.js";

export declare const rateLimit: <Function_1 extends AsyncFunction>(maxCalls: number, maxWeight: number, timeWindowMs: number, weight: (...args: Parameters<Function_1>) => number, f: Function_1) => Function_1;
export declare const semaphore: (max: number) => {
acquire: () => Promise<void>;
release: () => void;
};
export declare const throttle: <Function_1 extends AsyncFunction>(max: number) => (f: Function_1) => (...args: Parameters<Function_1>) => Promise<any>;
export declare const throttle: (max: number) => <F extends AsyncFunction>(f: F) => F;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.throttle = exports.semaphore = exports.rateLimit = exports.sequentialized = exports.keepTryingEvery50ms = void 0;
exports.throttle = exports.rateLimit = exports.sequentialized = exports.keepTryingEvery50ms = void 0;
const time_js_1 = require("./time.js");

@@ -86,17 +86,15 @@ const withLock = (lock, unlock, f) => (async (...args) => {

};
exports.semaphore = semaphore;
const throttle = (max) => {
const { acquire, release } = (0, exports.semaphore)(max);
return (f) => {
return async (...args) => {
await acquire();
try {
return await f(...args);
}
finally {
release();
}
};
const { acquire, release } = semaphore(max);
// @ts-expect-error too complex
return (f) => async (...args) => {
await acquire();
try {
return await f(...args);
}
finally {
release();
}
};
};
exports.throttle = throttle;
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