Socket
Socket
Sign inDemoInstall

@aws-sdk/endpoint-cache

Package Overview
Dependencies
Maintainers
5
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/endpoint-cache - npm Package Compare versions

Comparing version 3.186.0 to 3.188.0

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

# [3.188.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.187.0...v3.188.0) (2022-10-13)
**Note:** Version bump only for package @aws-sdk/endpoint-cache
# [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)

@@ -8,0 +16,0 @@

57

dist-es/EndpointCache.js
import LRUCache from "mnemonist/lru-cache";
var EndpointCache = (function () {
function EndpointCache(capacity) {
export class EndpointCache {
constructor(capacity) {
this.cache = new LRUCache(capacity);
}
EndpointCache.prototype.getEndpoint = function (key) {
var endpointsWithExpiry = this.get(key);
getEndpoint(key) {
const endpointsWithExpiry = this.get(key);
if (!endpointsWithExpiry || endpointsWithExpiry.length === 0) {
return undefined;
}
var endpoints = endpointsWithExpiry.map(function (endpoint) { return endpoint.Address; });
const endpoints = endpointsWithExpiry.map((endpoint) => endpoint.Address);
return endpoints[Math.floor(Math.random() * endpoints.length)];
};
EndpointCache.prototype.get = function (key) {
}
get(key) {
if (!this.has(key)) {
return;
}
var value = this.cache.get(key);
const value = this.cache.get(key);
if (!value) {
return;
}
var now = Date.now();
var endpointsWithExpiry = value.filter(function (endpoint) { return now < endpoint.Expires; });
const now = Date.now();
const endpointsWithExpiry = value.filter((endpoint) => now < endpoint.Expires);
if (endpointsWithExpiry.length === 0) {

@@ -29,21 +29,18 @@ this.delete(key);

return endpointsWithExpiry;
};
EndpointCache.prototype.set = function (key, endpoints) {
var now = Date.now();
this.cache.set(key, endpoints.map(function (_a) {
var Address = _a.Address, CachePeriodInMinutes = _a.CachePeriodInMinutes;
return ({
Address: Address,
Expires: now + CachePeriodInMinutes * 60 * 1000,
});
}));
};
EndpointCache.prototype.delete = function (key) {
}
set(key, endpoints) {
const now = Date.now();
this.cache.set(key, endpoints.map(({ Address, CachePeriodInMinutes }) => ({
Address,
Expires: now + CachePeriodInMinutes * 60 * 1000,
})));
}
delete(key) {
this.cache.set(key, []);
};
EndpointCache.prototype.has = function (key) {
}
has(key) {
if (!this.cache.has(key)) {
return false;
}
var endpoints = this.cache.peek(key);
const endpoints = this.cache.peek(key);
if (!endpoints) {

@@ -53,8 +50,6 @@ return false;

return endpoints.length > 0;
};
EndpointCache.prototype.clear = function () {
}
clear() {
this.cache.clear();
};
return EndpointCache;
}());
export { EndpointCache };
}
}
{
"name": "@aws-sdk/endpoint-cache",
"version": "3.186.0",
"version": "3.188.0",
"scripts": {

@@ -5,0 +5,0 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",

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