@sebspark/promise-cache 3.1.0 → 3.2.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/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -40,7 +30,6 @@ var import_node_crypto = require("crypto");
40
30
 
41
31
  // src/persistor.ts
42
32
  var import_redis = require("redis");
43
- var import_superjson = __toESM(require("superjson"));
44
33
 
45
34
  // src/localMemory.ts
46
35
  var LocalStorage = class {
@@ -84,6 +73,8 @@ var createLocalMemoryClient = () => {
84
73
  };
85
74
 
86
75
  // src/persistor.ts
76
+ var fixESM = require("fix-esm");
77
+ var superjson = fixESM.require("superjson");
87
78
  var CACHE_CLIENT = import_redis.createClient;
88
79
  var isTestRunning = process.env.NODE_ENV === "test";
89
80
  function toMillis(seconds) {
@@ -184,7 +175,7 @@ var Persistor = class {
184
175
  return;
185
176
  }
186
177
  try {
187
- const serializedData = import_superjson.default.stringify({
178
+ const serializedData = superjson.stringify({
188
179
  value,
189
180
  ttl,
190
181
  timestamp
@@ -212,7 +203,7 @@ var Persistor = class {
212
203
  if (!data) {
213
204
  return null;
214
205
  }
215
- return import_superjson.default.parse(data);
206
+ return superjson.parse(data);
216
207
  } catch (error) {
217
208
  (_b = this.logger) == null ? void 0 : _b.error(`Error getting data in redis: ${error}`);
218
209
  throw new Error(`Error getting data from redis: ${error}`);
package/dist/index.mjs CHANGED
@@ -1,9 +1,15 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
1
8
  // src/promiseCache.ts
2
9
  import { randomUUID } from "node:crypto";
3
10
 
4
11
  // src/persistor.ts
5
12
  import { createClient } from "redis";
6
- import superjson from "superjson";
7
13
 
8
14
  // src/localMemory.ts
9
15
  var LocalStorage = class {
@@ -47,6 +53,8 @@ var createLocalMemoryClient = () => {
47
53
  };
48
54
 
49
55
  // src/persistor.ts
56
+ var fixESM = __require("fix-esm");
57
+ var superjson = fixESM.require("superjson");
50
58
  var CACHE_CLIENT = createClient;
51
59
  var isTestRunning = process.env.NODE_ENV === "test";
52
60
  function toMillis(seconds) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sebspark/promise-cache",
3
- "version": "3.1.0",
3
+ "version": "3.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -19,6 +19,7 @@
19
19
  "tsconfig": "*"
20
20
  },
21
21
  "dependencies": {
22
+ "fix-esm": "^1.0.1",
22
23
  "redis": "4.7.0",
23
24
  "superjson": "^2.2.2"
24
25
  }