@sebspark/promise-cache 3.3.2 → 3.3.3

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/dist/index.js CHANGED
@@ -18,12 +18,12 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  Persistor: () => Persistor,
24
24
  PromiseCache: () => PromiseCache
25
25
  });
26
- module.exports = __toCommonJS(src_exports);
26
+ module.exports = __toCommonJS(index_exports);
27
27
 
28
28
  // src/promiseCache.ts
29
29
  var import_node_crypto = require("crypto");
@@ -291,7 +291,7 @@ var PromiseCache = class {
291
291
  });
292
292
  this.caseSensitive = caseSensitive;
293
293
  if (ttlInSeconds) {
294
- this.ttl = ttlInSeconds * 1e3;
294
+ this.ttl = ttlInSeconds;
295
295
  }
296
296
  }
297
297
  /**
@@ -335,7 +335,7 @@ var PromiseCache = class {
335
335
  async wrap(key, delegate, ttlInSeconds, ttlKeyInSeconds) {
336
336
  const now = Date.now();
337
337
  const effectiveKey = this.caseSensitive ? key : key.toLowerCase();
338
- let effectiveTTL = ttlInSeconds !== void 0 ? ttlInSeconds * 1e3 : this.ttl;
338
+ let effectiveTTL = ttlInSeconds ?? this.ttl;
339
339
  const cached = await this.persistor.get(effectiveKey);
340
340
  if (cached) {
341
341
  if (!ttlKeyInSeconds && cached.ttl !== effectiveTTL) {
@@ -348,7 +348,7 @@ var PromiseCache = class {
348
348
  const response = await delegate();
349
349
  if (ttlKeyInSeconds) {
350
350
  const responseDict = response;
351
- const responseTTL = Number(responseDict[ttlKeyInSeconds]) * 1e3;
351
+ const responseTTL = Number(responseDict[ttlKeyInSeconds]);
352
352
  effectiveTTL = responseTTL || effectiveTTL;
353
353
  }
354
354
  this.persistor.set(effectiveKey, {
package/dist/index.mjs CHANGED
@@ -271,7 +271,7 @@ var PromiseCache = class {
271
271
  });
272
272
  this.caseSensitive = caseSensitive;
273
273
  if (ttlInSeconds) {
274
- this.ttl = ttlInSeconds * 1e3;
274
+ this.ttl = ttlInSeconds;
275
275
  }
276
276
  }
277
277
  /**
@@ -315,7 +315,7 @@ var PromiseCache = class {
315
315
  async wrap(key, delegate, ttlInSeconds, ttlKeyInSeconds) {
316
316
  const now = Date.now();
317
317
  const effectiveKey = this.caseSensitive ? key : key.toLowerCase();
318
- let effectiveTTL = ttlInSeconds !== void 0 ? ttlInSeconds * 1e3 : this.ttl;
318
+ let effectiveTTL = ttlInSeconds ?? this.ttl;
319
319
  const cached = await this.persistor.get(effectiveKey);
320
320
  if (cached) {
321
321
  if (!ttlKeyInSeconds && cached.ttl !== effectiveTTL) {
@@ -328,7 +328,7 @@ var PromiseCache = class {
328
328
  const response = await delegate();
329
329
  if (ttlKeyInSeconds) {
330
330
  const responseDict = response;
331
- const responseTTL = Number(responseDict[ttlKeyInSeconds]) * 1e3;
331
+ const responseTTL = Number(responseDict[ttlKeyInSeconds]);
332
332
  effectiveTTL = responseTTL || effectiveTTL;
333
333
  }
334
334
  this.persistor.set(effectiveKey, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sebspark/promise-cache",
3
- "version": "3.3.2",
3
+ "version": "3.3.3",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -19,8 +19,8 @@
19
19
  "tsconfig": "*"
20
20
  },
21
21
  "dependencies": {
22
- "fix-esm": "^1.0.1",
22
+ "fix-esm": "1.0.1",
23
23
  "redis": "4.7.0",
24
- "superjson": "^2.2.2"
24
+ "superjson": "2.2.2"
25
25
  }
26
26
  }