oblivious-set
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -9,2 +9,7 @@ /** | ||
readonly map: Map<any, any>; | ||
/** | ||
* Creating calls to setTimeout() is expensive, | ||
* so we only do that if there is not timeout already open. | ||
*/ | ||
_to: boolean; | ||
constructor(ttl: number); | ||
@@ -11,0 +16,0 @@ has(value: T): boolean; |
@@ -10,2 +10,7 @@ /** | ||
this.map = new Map(); | ||
/** | ||
* Creating calls to setTimeout() is expensive, | ||
* so we only do that if there is not timeout already open. | ||
*/ | ||
this._to = false; | ||
} | ||
@@ -24,5 +29,9 @@ ObliviousSet.prototype.has = function (value) { | ||
*/ | ||
setTimeout(function () { | ||
removeTooOldValues(_this); | ||
}, 0); | ||
if (!this._to) { | ||
this._to = true; | ||
setTimeout(function () { | ||
_this._to = false; | ||
removeTooOldValues(_this); | ||
}, 0); | ||
} | ||
}; | ||
@@ -29,0 +38,0 @@ ObliviousSet.prototype.clear = function () { |
@@ -9,2 +9,7 @@ /** | ||
readonly map: Map<any, any>; | ||
/** | ||
* Creating calls to setTimeout() is expensive, | ||
* so we only do that if there is not timeout already open. | ||
*/ | ||
_to: boolean; | ||
constructor(ttl: number); | ||
@@ -11,0 +16,0 @@ has(value: T): boolean; |
@@ -13,2 +13,7 @@ "use strict"; | ||
this.map = new Map(); | ||
/** | ||
* Creating calls to setTimeout() is expensive, | ||
* so we only do that if there is not timeout already open. | ||
*/ | ||
this._to = false; | ||
} | ||
@@ -27,5 +32,9 @@ ObliviousSet.prototype.has = function (value) { | ||
*/ | ||
setTimeout(function () { | ||
removeTooOldValues(_this); | ||
}, 0); | ||
if (!this._to) { | ||
this._to = true; | ||
setTimeout(function () { | ||
_this._to = false; | ||
removeTooOldValues(_this); | ||
}, 0); | ||
} | ||
}; | ||
@@ -32,0 +41,0 @@ ObliviousSet.prototype.clear = function () { |
{ | ||
"name": "oblivious-set", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Like a JavaScript Set() but with a TTL for entries", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -9,2 +9,8 @@ | ||
public readonly map = new Map(); | ||
/** | ||
* Creating calls to setTimeout() is expensive, | ||
* so we only do that if there is not timeout already open. | ||
*/ | ||
public _to: boolean = false; | ||
constructor( | ||
@@ -27,5 +33,9 @@ public readonly ttl: number | ||
*/ | ||
setTimeout(() => { | ||
removeTooOldValues(this); | ||
}, 0); | ||
if (!this._to) { | ||
this._to = true; | ||
setTimeout(() => { | ||
this._to = false; | ||
removeTooOldValues(this); | ||
}, 0); | ||
} | ||
} | ||
@@ -32,0 +42,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18915
460