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

async-ratelimiter

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-ratelimiter - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

9

CHANGELOG.md

@@ -0,1 +1,10 @@

<a name="1.1.0"></a>
# 1.1.0 (2018-07-16)
* allow custom duration in .get ([f3edcf2](https://github.com/microlinkhq/async-ratelimiter/commit/f3edcf2))
* allow custom limits ([a94f501](https://github.com/microlinkhq/async-ratelimiter/commit/a94f501))
* keep responsibility of tests ([2fd9903](https://github.com/microlinkhq/async-ratelimiter/commit/2fd9903))
<a name="1.0.2"></a>

@@ -2,0 +11,0 @@ ## 1.0.2 (2018-06-18)

10

package.json

@@ -5,3 +5,3 @@ {

"homepage": "https://documentup.com/microlinkhq/async-ratelimiter",
"version": "1.0.2",
"version": "1.1.0",
"main": "src/index.js",

@@ -15,4 +15,4 @@ "author": {

{
"name": "TJ Holowaychuk",
"email": "tj@vision-media.ca"
"name": "Noam Shemesh",
"email": "noam@bigpanda.io"
},

@@ -68,4 +68,4 @@ {

{
"name": "Noam Shemesh",
"email": "noam@bigpanda.io"
"name": "TJ Holowaychuk",
"email": "tj@vision-media.ca"
},

@@ -72,0 +72,0 @@ {

@@ -110,2 +110,15 @@ # async-ratelimiter

##### max
Type: `number`
The maximum number of requests within `duration`. If provided, it overrides the default `max` value. This is useful for custom limits that differ between IDs.
##### duration
Type: `number`
How long keep records of requests in milliseconds. If provided, it overrides the default `duration` value.
## License

@@ -112,0 +125,0 @@

@@ -17,6 +17,8 @@ 'use strict'

async get ({ id = this.id } = {}) {
async get ({ id = this.id, max = this.max, duration = this.duration } = {}) {
assert(id, 'id required')
assert(max, 'max required')
assert(duration, 'duration required')
const { db, duration, max } = this
const { db } = this
const key = `${this.namespace}:${id}`

@@ -23,0 +25,0 @@ const now = microtime.now()

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