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

@aws-sdk/endpoint-cache

Package Overview
Dependencies
Maintainers
5
Versions
36
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.170.0 to 3.183.0

8

CHANGELOG.md

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

# [3.183.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.182.0...v3.183.0) (2022-10-03)
**Note:** Version bump only for package @aws-sdk/endpoint-cache
# [3.170.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.169.0...v3.170.0) (2022-09-13)

@@ -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 };
}
}
export interface Endpoint {
Address: string;
CachePeriodInMinutes: number;
}

@@ -8,14 +8,8 @@ import { Endpoint } from "./Endpoint";

constructor(capacity: number);
getEndpoint(key: string): string | undefined;
get(key: string): EndpointWithExpiry[] | undefined;
set(key: string, endpoints: Endpoint[]): void;
delete(key: string): void;
has(key: string): boolean;
clear(): void;
}
{
"name": "@aws-sdk/endpoint-cache",
"version": "3.170.0",
"version": "3.183.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