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

rolling-rate-limiter

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rolling-rate-limiter - npm Package Compare versions

Comparing version 0.2.12 to 0.2.13

4

lib/index.js

@@ -8,2 +8,3 @@ "use strict";

const assert_1 = __importDefault(require("assert"));
const microtime_1 = __importDefault(require("microtime"));
const uuid_1 = require("uuid");

@@ -190,4 +191,3 @@ /**

function getCurrentMicroseconds() {
const hr = process.hrtime();
return (hr[0] * 1e6 + Math.ceil(hr[1] / 1000));
return microtime_1.default.now();
}

@@ -194,0 +194,0 @@ exports.getCurrentMicroseconds = getCurrentMicroseconds;

@@ -6,4 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const process_1 = __importDefault(require("process"));
const ioredis_1 = __importDefault(require("ioredis"));
const microtime_1 = __importDefault(require("microtime"));
const redis_1 = __importDefault(require("redis"));

@@ -68,7 +68,4 @@ const _1 = require(".");

jest
.spyOn(process_1.default, 'hrtime')
.mockImplementation(() => [
Math.floor(timeInMilliseconds / 1e3),
(timeInMilliseconds % 1e3) * 1e6,
]);
.spyOn(microtime_1.default, 'now')
.mockImplementation(() => (0, _1.millisecondsToMicroseconds)(timeInMilliseconds));
jest.advanceTimersByTime(Math.max(0, timeInMilliseconds - currentTime));

@@ -75,0 +72,0 @@ currentTime = timeInMilliseconds;

{
"name": "rolling-rate-limiter",
"version": "0.2.12",
"version": "0.2.13",
"description": "Rate limiter that supports a rolling window, either in-memory or backed by Redis",

@@ -41,2 +41,3 @@ "main": "lib/index.js",

"dependencies": {
"microtime": "^3.0.0",
"uuid": "^8.3.0"

@@ -47,2 +48,3 @@ },

"@types/jest": "^26.0.23",
"@types/microtime": "^2.1.0",
"@types/node": "^15.0.1",

@@ -49,0 +51,0 @@ "@types/redis": "^2.8.28",

@@ -1,3 +0,3 @@

import process from 'process';
import IORedis from 'ioredis';
import microtime from 'microtime';
import redis from 'redis';

@@ -10,2 +10,4 @@

RedisRateLimiter,
millisecondsToMicroseconds,
Milliseconds,
} from '.';

@@ -82,7 +84,6 @@

jest
.spyOn(process, 'hrtime')
.mockImplementation(() => [
Math.floor(timeInMilliseconds / 1e3),
(timeInMilliseconds % 1e3) * 1e6,
]);
.spyOn(microtime, 'now')
.mockImplementation(() =>
millisecondsToMicroseconds(timeInMilliseconds as Milliseconds),
);
jest.advanceTimersByTime(Math.max(0, timeInMilliseconds - currentTime));

@@ -89,0 +90,0 @@ currentTime = timeInMilliseconds;

import assert from 'assert';
import microtime from 'microtime';
import { v4 as uuid } from 'uuid';

@@ -280,4 +281,3 @@

export function getCurrentMicroseconds() {
const hr = process.hrtime();
return (hr[0] * 1e6 + Math.ceil(hr[1] / 1000)) as Microseconds;
return microtime.now() as Microseconds;
}

@@ -284,0 +284,0 @@

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