@aws-sdk/endpoint-cache 3.186.0 → 3.201.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.201.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.200.0...v3.201.0) (2022-11-01)
7
+
8
+
9
+ ### Features
10
+
11
+ * end support for Node.js 12.x ([#4123](https://github.com/aws/aws-sdk-js-v3/issues/4123)) ([83f913e](https://github.com/aws/aws-sdk-js-v3/commit/83f913ec2ac3878d8726c6964f585550dc5caf3e))
12
+
13
+
14
+
15
+
16
+
17
+ # [3.188.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.187.0...v3.188.0) (2022-10-13)
18
+
19
+ **Note:** Version bump only for package @aws-sdk/endpoint-cache
20
+
21
+
22
+
23
+
24
+
6
25
  # [3.186.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.185.0...v3.186.0) (2022-10-06)
7
26
 
8
27
  **Note:** Version bump only for package @aws-sdk/endpoint-cache
@@ -1,58 +1,53 @@
1
1
  import LRUCache from "mnemonist/lru-cache";
2
- var EndpointCache = (function () {
3
- function EndpointCache(capacity) {
2
+ export class EndpointCache {
3
+ constructor(capacity) {
4
4
  this.cache = new LRUCache(capacity);
5
5
  }
6
- EndpointCache.prototype.getEndpoint = function (key) {
7
- var endpointsWithExpiry = this.get(key);
6
+ getEndpoint(key) {
7
+ const endpointsWithExpiry = this.get(key);
8
8
  if (!endpointsWithExpiry || endpointsWithExpiry.length === 0) {
9
9
  return undefined;
10
10
  }
11
- var endpoints = endpointsWithExpiry.map(function (endpoint) { return endpoint.Address; });
11
+ const endpoints = endpointsWithExpiry.map((endpoint) => endpoint.Address);
12
12
  return endpoints[Math.floor(Math.random() * endpoints.length)];
13
- };
14
- EndpointCache.prototype.get = function (key) {
13
+ }
14
+ get(key) {
15
15
  if (!this.has(key)) {
16
16
  return;
17
17
  }
18
- var value = this.cache.get(key);
18
+ const value = this.cache.get(key);
19
19
  if (!value) {
20
20
  return;
21
21
  }
22
- var now = Date.now();
23
- var endpointsWithExpiry = value.filter(function (endpoint) { return now < endpoint.Expires; });
22
+ const now = Date.now();
23
+ const endpointsWithExpiry = value.filter((endpoint) => now < endpoint.Expires);
24
24
  if (endpointsWithExpiry.length === 0) {
25
25
  this.delete(key);
26
26
  return undefined;
27
27
  }
28
28
  return endpointsWithExpiry;
29
- };
30
- EndpointCache.prototype.set = function (key, endpoints) {
31
- var now = Date.now();
32
- this.cache.set(key, endpoints.map(function (_a) {
33
- var Address = _a.Address, CachePeriodInMinutes = _a.CachePeriodInMinutes;
34
- return ({
35
- Address: Address,
36
- Expires: now + CachePeriodInMinutes * 60 * 1000,
37
- });
38
- }));
39
- };
40
- EndpointCache.prototype.delete = function (key) {
29
+ }
30
+ set(key, endpoints) {
31
+ const now = Date.now();
32
+ this.cache.set(key, endpoints.map(({ Address, CachePeriodInMinutes }) => ({
33
+ Address,
34
+ Expires: now + CachePeriodInMinutes * 60 * 1000,
35
+ })));
36
+ }
37
+ delete(key) {
41
38
  this.cache.set(key, []);
42
- };
43
- EndpointCache.prototype.has = function (key) {
39
+ }
40
+ has(key) {
44
41
  if (!this.cache.has(key)) {
45
42
  return false;
46
43
  }
47
- var endpoints = this.cache.peek(key);
44
+ const endpoints = this.cache.peek(key);
48
45
  if (!endpoints) {
49
46
  return false;
50
47
  }
51
48
  return endpoints.length > 0;
52
- };
53
- EndpointCache.prototype.clear = function () {
49
+ }
50
+ clear() {
54
51
  this.cache.clear();
55
- };
56
- return EndpointCache;
57
- }());
58
- export { EndpointCache };
52
+ }
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-sdk/endpoint-cache",
3
- "version": "3.186.0",
3
+ "version": "3.201.0",
4
4
  "scripts": {
5
5
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
6
6
  "build:cjs": "tsc -p tsconfig.cjs.json",
@@ -33,7 +33,7 @@
33
33
  "typescript": "~4.6.2"
34
34
  },
35
35
  "engines": {
36
- "node": ">= 12.0.0"
36
+ "node": ">=14.0.0"
37
37
  },
38
38
  "typesVersions": {
39
39
  "<4.0": {