@envelop/parser-cache 4.4.0 → 4.5.0-alpha-3ae66da.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/README.md CHANGED
@@ -13,17 +13,17 @@ yarn add @envelop/parser-cache
13
13
  ## Usage Example
14
14
 
15
15
  ```ts
16
- import { envelop } from '@envelop/core';
17
- import { useParserCache } from '@envelop/parser-cache';
16
+ import { envelop } from '@envelop/core'
17
+ import { useParserCache } from '@envelop/parser-cache'
18
18
 
19
19
  const getEnveloped = envelop({
20
20
  plugins: [
21
21
  // ... other plugins ...
22
22
  useParserCache({
23
23
  // options goes here
24
- }),
25
- ],
26
- });
24
+ })
25
+ ]
26
+ })
27
27
  ```
28
28
 
29
29
  ### API Reference
package/cjs/index.js CHANGED
@@ -3,14 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useParserCache = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const graphql_1 = require("graphql");
6
- const tiny_lru_1 = tslib_1.__importDefault(require("tiny-lru"));
6
+ const lru_cache_1 = tslib_1.__importDefault(require("lru-cache"));
7
7
  const DEFAULT_MAX = 1000;
8
8
  const DEFAULT_TTL = 3600000;
9
9
  const useParserCache = (pluginOptions = {}) => {
10
10
  const documentCache = typeof pluginOptions.documentCache !== 'undefined'
11
11
  ? pluginOptions.documentCache
12
- : (0, tiny_lru_1.default)(DEFAULT_MAX, DEFAULT_TTL);
13
- const errorCache = typeof pluginOptions.errorCache !== 'undefined' ? pluginOptions.errorCache : (0, tiny_lru_1.default)(DEFAULT_MAX, DEFAULT_TTL);
12
+ : new lru_cache_1.default({ max: DEFAULT_MAX, maxAge: DEFAULT_TTL });
13
+ const errorCache = typeof pluginOptions.errorCache !== 'undefined'
14
+ ? pluginOptions.errorCache
15
+ : new lru_cache_1.default({ max: DEFAULT_MAX, maxAge: DEFAULT_TTL });
14
16
  return {
15
17
  onParse({ params, setParsedDocument }) {
16
18
  const { source } = params;
package/esm/index.js CHANGED
@@ -1,12 +1,14 @@
1
1
  import { Source } from 'graphql';
2
- import lru from 'tiny-lru';
2
+ import LRU from 'lru-cache';
3
3
  const DEFAULT_MAX = 1000;
4
4
  const DEFAULT_TTL = 3600000;
5
5
  export const useParserCache = (pluginOptions = {}) => {
6
6
  const documentCache = typeof pluginOptions.documentCache !== 'undefined'
7
7
  ? pluginOptions.documentCache
8
- : lru(DEFAULT_MAX, DEFAULT_TTL);
9
- const errorCache = typeof pluginOptions.errorCache !== 'undefined' ? pluginOptions.errorCache : lru(DEFAULT_MAX, DEFAULT_TTL);
8
+ : new LRU({ max: DEFAULT_MAX, maxAge: DEFAULT_TTL });
9
+ const errorCache = typeof pluginOptions.errorCache !== 'undefined'
10
+ ? pluginOptions.errorCache
11
+ : new LRU({ max: DEFAULT_MAX, maxAge: DEFAULT_TTL });
10
12
  return {
11
13
  onParse({ params, setParsedDocument }) {
12
14
  const { source } = params;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@envelop/parser-cache",
3
- "version": "4.4.0",
3
+ "version": "4.5.0-alpha-3ae66da.0",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
6
  "@envelop/core": "^2.4.0",
7
7
  "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
8
8
  },
9
9
  "dependencies": {
10
- "tiny-lru": "7.0.6"
10
+ "lru-cache": "^6.0.0"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",