limited-cache 2.0.0 → 2.1.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/CODE_OF_CONDUCT.md +103 -47
  3. package/{CONTRIBUTING.md → CONTRIBUTING.template.md} +4 -2
  4. package/LICENSE +1 -1
  5. package/README.md +2 -2
  6. package/dist/core/LimitedCache.d.ts +4 -3
  7. package/dist/core/LimitedCache.d.ts.map +1 -0
  8. package/dist/core/LimitedCache.js +29 -0
  9. package/dist/core/LimitedCache.js.map +1 -0
  10. package/dist/core/LimitedCacheObject.d.ts +5 -4
  11. package/dist/core/LimitedCacheObject.d.ts.map +1 -0
  12. package/dist/core/LimitedCacheObject.js +52 -0
  13. package/dist/core/LimitedCacheObject.js.map +1 -0
  14. package/dist/core/builtIns.d.ts +12 -11
  15. package/dist/core/builtIns.d.ts.map +1 -0
  16. package/dist/core/builtIns.js +5 -0
  17. package/dist/core/builtIns.js.map +1 -0
  18. package/dist/core/defaultOptions.d.ts +6 -5
  19. package/dist/core/defaultOptions.d.ts.map +1 -0
  20. package/dist/core/defaultOptions.js +14 -0
  21. package/dist/core/defaultOptions.js.map +1 -0
  22. package/dist/core/limitedCacheUtil.d.ts +13 -12
  23. package/dist/core/limitedCacheUtil.d.ts.map +1 -0
  24. package/dist/core/limitedCacheUtil.js +14 -0
  25. package/dist/core/limitedCacheUtil.js.map +1 -0
  26. package/dist/core/lowLevelFunctions.d.ts +14 -13
  27. package/dist/core/lowLevelFunctions.d.ts.map +1 -0
  28. package/dist/core/lowLevelFunctions.js +240 -0
  29. package/dist/core/lowLevelFunctions.js.map +1 -0
  30. package/dist/index.cjs +388 -0
  31. package/dist/index.d.ts +7 -6
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +7 -8
  34. package/dist/index.js.map +1 -0
  35. package/dist/types.d.ts +58 -60
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/types.js +2 -0
  38. package/dist/types.js.map +1 -0
  39. package/package.json +82 -74
  40. package/src/__tests__/LimitedCache.test.ts +5 -5
  41. package/src/__tests__/LimitedCacheObject.test.ts +6 -4
  42. package/src/__tests__/lowLevelFunctions.test.ts +17 -13
  43. package/src/__tests__/scenarios/keys.test.ts +1 -1
  44. package/src/__tests__/scenarios/maxCacheSize.test.ts +3 -3
  45. package/src/__tests__/scenarios/maxCacheTime.test.ts +2 -2
  46. package/src/__tests__/scenarios/values.test.ts +1 -1
  47. package/src/__tests__/typeChecks/LimitedCacheObjectTypes.test.ts +4 -2
  48. package/src/__tests__/typeChecks/LimitedCacheTypes.test.ts +4 -2
  49. package/src/__tests__/typeChecks/lowLevelFunctionsTypes.test.ts +4 -2
  50. package/src/core/lowLevelFunctions.ts +5 -5
  51. package/dist/limited-cache.cjs.development.js +0 -469
  52. package/dist/limited-cache.cjs.development.js.map +0 -1
  53. package/dist/limited-cache.cjs.production.min.js +0 -2
  54. package/dist/limited-cache.cjs.production.min.js.map +0 -1
  55. package/dist/limited-cache.esm.js +0 -448
  56. package/dist/limited-cache.esm.js.map +0 -1
  57. package/legacy-types/ts3.x/dist/core/LimitedCache.d.ts +0 -3
  58. package/legacy-types/ts3.x/dist/core/LimitedCacheObject.d.ts +0 -4
  59. package/legacy-types/ts3.x/dist/core/builtIns.d.ts +0 -11
  60. package/legacy-types/ts3.x/dist/core/defaultOptions.d.ts +0 -5
  61. package/legacy-types/ts3.x/dist/core/limitedCacheUtil.d.ts +0 -12
  62. package/legacy-types/ts3.x/dist/core/lowLevelFunctions.d.ts +0 -13
  63. package/legacy-types/ts3.x/dist/index.d.ts +0 -6
  64. package/legacy-types/ts3.x/dist/types.d.ts +0 -60
package/CHANGELOG.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Update and modernize package build ([#56](https://github.com/spautz/package-template/issues/56)) ([5f210a6](https://github.com/spautz/package-template/commit/5f210a6a5f77cdffe73f004ea4574f4e791e5029))
8
+ - Add NPM provenance via Github actions ([#56](https://github.com/spautz/package-template/issues/56)) ([5f210a6](https://github.com/spautz/package-template/commit/5f210a6a5f77cdffe73f004ea4574f4e791e5029))
9
+ - Confirm support for Node 20 ([#56](https://github.com/spautz/package-template/issues/56)) ([5f210a6](https://github.com/spautz/package-template/commit/5f210a6a5f77cdffe73f004ea4574f4e791e5029))
4
10
 
5
11
  ## [2.0.0](https://github.com/spautz/limited-cache/compare/v1.1.1...v2.0.0) (2021-10-23)
6
12
 
@@ -2,75 +2,131 @@
2
2
 
3
3
  ## Our Pledge
4
4
 
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, sex characteristics, gender identity and expression,
9
- level of experience, education, socio-economic status, nationality, personal
10
- appearance, race, religion, or sexual identity and orientation.
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual identity
10
+ and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
11
14
 
12
15
  ## Our Standards
13
16
 
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
16
19
 
17
- - Using welcoming and inclusive language
18
- - Being respectful of differing viewpoints and experiences
19
- - Gracefully accepting constructive criticism
20
- - Focusing on what is best for the community
21
- - Showing empathy towards other community members
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ - Focusing on what is best not just for us as individuals, but for the
26
+ overall community
22
27
 
23
- Examples of unacceptable behavior by participants include:
28
+ Examples of unacceptable behavior include:
24
29
 
25
- - The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- - Trolling, insulting/derogatory comments, and personal or political attacks
30
+ - The use of sexualized language or imagery, and sexual attention or
31
+ advances of any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
28
33
  - Public or private harassment
29
- - Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
34
+ - Publishing others' private information, such as a physical or email
35
+ address, without their explicit permission
31
36
  - Other conduct which could reasonably be considered inappropriate in a
32
37
  professional setting
33
38
 
34
- ## Our Responsibilities
39
+ ## Enforcement Responsibilities
35
40
 
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
39
45
 
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
45
50
 
46
51
  ## Scope
47
52
 
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
54
58
 
55
59
  ## Enforcement
56
60
 
57
61
  Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at spautz@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
62
+ reported to the community leaders responsible for enforcement at
63
+ spautz@gmail.com.
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series
86
+ of actions.
63
87
 
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or
93
+ permanent ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within
113
+ the community.
67
114
 
68
115
  ## Attribution
69
116
 
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.0, available at
119
+ [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
72
120
 
73
- [homepage]: https://www.contributor-covenant.org
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][mozilla coc].
74
123
 
75
- For answers to common questions about this code of conduct, see
76
- https://www.contributor-covenant.org/faq
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][faq]. Translations are available
126
+ at [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
130
+ [mozilla coc]: https://github.com/mozilla/diversity
131
+ [faq]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
@@ -40,11 +40,13 @@ to discuss your idea and make sure it is inline with the project goals.
40
40
  4. To test your local dev version of `limited-cache` in other projects, [Yalc](https://github.com/whitecolor/yalc)
41
41
  is an excellent tool.
42
42
 
43
- 5. After you have made your changes, submit a pull request. Issues and pull requests are monitored, and you should receive a reply.
43
+ 5. After you have made your changes, submit a pull request. Issues and pull requests are monitored, and you should
44
+ receive a reply.
44
45
 
45
46
  ## Code and Project Standards
46
47
 
47
- Eslint, Typescript, and Prettier enforce most code standards. A pre-push hook will validate the project against those standards.
48
+ Eslint, Typescript, and Prettier enforce most code standards.
49
+ A pre-push hook will validate the project against those standards.
48
50
 
49
51
  Running `yarn test` will check the code against unit tests and generate a code coverage report (in `coverage/`).
50
52
  This project's goal is to be near 100% code coverage.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 Steven Pautz
3
+ Copyright (c) 2022 Steven Pautz
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -4,9 +4,9 @@ A minimal JS cache. Like using an object to store keys and values, except it won
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/limited-cache.svg)](https://www.npmjs.com/package/limited-cache)
6
6
  [![build status](https://github.com/spautz/limited-cache/workflows/CI/badge.svg)](https://github.com/spautz/limited-cache/actions)
7
- [![dependencies status](https://img.shields.io/badge/dependencies-none-brightgreen.svg)](https://david-dm.org/spautz/limited-cache)
8
- [![gzip size](https://img.badgesize.io/https://unpkg.com/limited-cache@latest/dist/limited-cache.cjs.production.min.js?compression=gzip)](https://bundlephobia.com/result?p=limited-cache)
9
7
  [![test coverage](https://img.shields.io/coveralls/github/spautz/limited-cache/main.svg)](https://coveralls.io/github/spautz/limited-cache?branch=main)
8
+ [![dependencies status](https://img.shields.io/librariesio/release/npm/limited-cache.svg)](https://libraries.io/github/spautz/limited-cache)
9
+ [![gzip size](https://img.badgesize.io/https://unpkg.com/limited-cache@latest/dist/index.cjs?compression=gzip)](https://bundlephobia.com/result?p=limited-cache)
10
10
 
11
11
  ## Motivation
12
12
 
@@ -1,3 +1,4 @@
1
- import { LimitedCacheInstance } from '../types';
2
- declare const LimitedCache: <ItemType = any>(options?: Partial<import("../types").LimitedCacheOptionsFull> | null | undefined) => LimitedCacheInstance<ItemType>;
3
- export { LimitedCache };
1
+ import { LimitedCacheOptions, LimitedCacheInstance } from '../types';
2
+ declare const LimitedCache: <ItemType = any>(options?: LimitedCacheOptions) => LimitedCacheInstance<ItemType>;
3
+ export { LimitedCache };
4
+ //# sourceMappingURL=LimitedCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LimitedCache.d.ts","sourceRoot":"","sources":["../../src/core/LimitedCache.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,mBAAmB,EAEnB,oBAAoB,EAGrB,MAAM,UAAU,CAAC;AAUlB,QAAA,MAAM,YAAY,6BACN,mBAAmB,mCAsB9B,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { lowLevelInit, lowLevelGetOne, lowLevelGetAll, lowLevelHas, lowLevelSet, lowLevelRemove, lowLevelReset, lowLevelSetOptions, lowLevelDoMaintenance, } from './lowLevelFunctions';
2
+ // Most public functions just call a low-level function directly, passing the cacheMeta.
3
+ // Doing this via a helper function makes the typeChecks easier, and minifies better.
4
+ const bindFunctionToCacheMeta = (
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+ fn, cacheMeta) => fn.bind(null, cacheMeta);
7
+ const LimitedCache = (options) => {
8
+ const cacheMeta = lowLevelInit(options);
9
+ return {
10
+ get: bindFunctionToCacheMeta(lowLevelGetOne, cacheMeta),
11
+ getAll: bindFunctionToCacheMeta(lowLevelGetAll, cacheMeta),
12
+ has: bindFunctionToCacheMeta(lowLevelHas, cacheMeta),
13
+ set: (cacheKey, item) => {
14
+ lowLevelSet(cacheMeta, cacheKey, item);
15
+ return item;
16
+ },
17
+ remove: (cacheKey) => {
18
+ lowLevelRemove(cacheMeta, cacheKey);
19
+ return true;
20
+ },
21
+ reset: bindFunctionToCacheMeta(lowLevelReset, cacheMeta),
22
+ getCacheMeta: () => cacheMeta,
23
+ getOptions: () => cacheMeta.options,
24
+ setOptions: bindFunctionToCacheMeta(lowLevelSetOptions, cacheMeta),
25
+ doMaintenance: bindFunctionToCacheMeta(lowLevelDoMaintenance, cacheMeta),
26
+ };
27
+ };
28
+ export { LimitedCache };
29
+ //# sourceMappingURL=LimitedCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LimitedCache.js","source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F,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -1,4 +1,5 @@
1
- import { LimitedCacheObjectInstance, LimitedCacheMeta } from '../types';
2
- declare const LimitedCacheObject: <ItemType = any>(options?: Partial<import("../types").LimitedCacheOptionsFull> | null | undefined) => LimitedCacheObjectInstance<ItemType>;
3
- declare const getCacheMetaFromObject: (instance: LimitedCacheObjectInstance) => LimitedCacheMeta;
4
- export { LimitedCacheObject, getCacheMetaFromObject };
1
+ import { LimitedCacheOptions, LimitedCacheObjectInstance, LimitedCacheMeta } from '../types';
2
+ declare const LimitedCacheObject: <ItemType = any>(options?: LimitedCacheOptions) => LimitedCacheObjectInstance<ItemType>;
3
+ declare const getCacheMetaFromObject: (instance: LimitedCacheObjectInstance) => LimitedCacheMeta;
4
+ export { LimitedCacheObject, getCacheMetaFromObject };
5
+ //# sourceMappingURL=LimitedCacheObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LimitedCacheObject.d.ts","sourceRoot":"","sources":["../../src/core/LimitedCacheObject.ts"],"names":[],"mappings":"AASA,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,gBAAgB,EAEjB,MAAM,UAAU,CAAC;AA4ClB,QAAA,MAAM,kBAAkB,6BACZ,mBAAmB,yCAO9B,CAAC;AAEF,QAAA,MAAM,sBAAsB,aAAc,0BAA0B,KAAG,gBAEtE,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { hasOwnProperty } from './builtIns';
2
+ import { lowLevelInit, lowLevelGetOne, lowLevelGetAll, lowLevelHas, lowLevelSet, lowLevelRemove, } from './lowLevelFunctions';
3
+ // The `any` here doesn't escape out anywhere: it's overridden by the constructor below
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ const proxyHandler = {
6
+ get: (cacheMeta, cacheKey) => {
7
+ if (cacheKey === 'hasOwnProperty') {
8
+ return hasOwnProperty;
9
+ }
10
+ return lowLevelGetOne(cacheMeta, cacheKey);
11
+ },
12
+ getOwnPropertyDescriptor: (cacheMeta, cacheKey) => {
13
+ const hasResult = lowLevelHas(cacheMeta, cacheKey);
14
+ const getResult = lowLevelGetOne(cacheMeta, cacheKey);
15
+ if (hasResult) {
16
+ return {
17
+ configurable: true,
18
+ enumerable: hasResult,
19
+ value: getResult,
20
+ writable: true,
21
+ };
22
+ }
23
+ return;
24
+ },
25
+ has: lowLevelHas,
26
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
+ set: (cacheMeta, cacheKey, item) => {
28
+ lowLevelSet(cacheMeta, cacheKey, item);
29
+ return item;
30
+ },
31
+ deleteProperty: (cacheMeta, cacheKey) => {
32
+ lowLevelRemove(cacheMeta, cacheKey);
33
+ return true;
34
+ },
35
+ ownKeys: (cacheMeta) => Object.keys(lowLevelGetAll(cacheMeta)),
36
+ };
37
+ /**
38
+ * So that we can retrieve the cacheMeta for a LimitedCacheObject, without polluting its properties, each proxy
39
+ * is associated back to its internal cacheMeta here.
40
+ */
41
+ const cacheMetasForProxies = new WeakMap();
42
+ const LimitedCacheObject = (options) => {
43
+ const cacheMeta = lowLevelInit(options);
44
+ const limitedCacheObject = new Proxy(cacheMeta, proxyHandler);
45
+ cacheMetasForProxies.set(limitedCacheObject, cacheMeta);
46
+ return limitedCacheObject;
47
+ };
48
+ const getCacheMetaFromObject = (instance) => {
49
+ return cacheMetasForProxies.get(instance);
50
+ };
51
+ export { LimitedCacheObject, getCacheMetaFromObject };
52
+ //# sourceMappingURL=LimitedCacheObject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LimitedCacheObject.js","sourceRoot":"","sources":["../../src/core/LimitedCacheObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,WAAW,EACX,WAAW,EACX,cAAc,GACf,MAAM,qBAAqB,CAAC;AAQ7B,uFA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AC;IACxC,MAAM,kBAAkB,GAAG,IAAI,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAE9D,oBAAoB,CAAC,GAAG,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;IACxD,OAAO,kBAAkB,CAAC;AAC5B,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,QAAoC,EAAoB,EAAE;IACxF,OAAO,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC5C,CAAC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,CAAC"}
@@ -1,11 +1,12 @@
1
- declare const objectCreate: {
2
- (o: object | null): any;
3
- (o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
4
- }, objectAssign: {
5
- <T, U>(target: T, source: U): T & U;
6
- <T_1, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
7
- <T_2, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
8
- (target: object, ...sources: any[]): any;
9
- }, hasOwnProperty: (v: string | number | symbol) => boolean;
10
- declare const dateNow: () => number;
11
- export { objectAssign, objectCreate, dateNow, hasOwnProperty };
1
+ declare const objectCreate: {
2
+ (o: object | null): any;
3
+ (o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
4
+ }, objectAssign: {
5
+ <T extends {}, U>(target: T, source: U): T & U;
6
+ <T_1 extends {}, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
7
+ <T_2 extends {}, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
8
+ (target: object, ...sources: any[]): any;
9
+ }, hasOwnProperty: (v: PropertyKey) => boolean;
10
+ declare const dateNow: () => number;
11
+ export { objectAssign, objectCreate, dateNow, hasOwnProperty };
12
+ //# sourceMappingURL=builtIns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtIns.d.ts","sourceRoot":"","sources":["../../src/core/builtIns.ts"],"names":[],"mappings":"AACA,QAAA,MACU,YAAY;;;GACZ,YAAY;;;;;GACP,cAAc,6BACnB,CAAC;AACX,QAAA,MAAM,OAAO,cAAW,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,5 @@
1
+ // To help minification
2
+ const { create: objectCreate, assign: objectAssign, prototype: { hasOwnProperty }, } = Object;
3
+ const dateNow = Date.now;
4
+ export { objectAssign, objectCreate, dateNow, hasOwnProperty };
5
+ //# sourceMappingURL=builtIns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builtIns.js","sourceRoot":"","sources":["../../src/core/builtIns.ts"],"names":[],"mappings":"AAAA,uBAAuB;AACvB,MAAM,EACJ,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,EAAE,cAAc,EAAE,GAC9B,GAAG,MAAM,CAAC;AACX,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -1,5 +1,6 @@
1
- import { LimitedCacheOptionsReadonly } from '../types';
2
- declare const CURRENT_META_VERSION = 2;
3
- declare const MAXIMUM_CACHE_TIME: number;
4
- declare const defaultOptions: LimitedCacheOptionsReadonly;
5
- export { CURRENT_META_VERSION, MAXIMUM_CACHE_TIME, defaultOptions };
1
+ import { LimitedCacheOptionsReadonly } from '../types';
2
+ declare const CURRENT_META_VERSION = 2;
3
+ declare const MAXIMUM_CACHE_TIME: number;
4
+ declare const defaultOptions: LimitedCacheOptionsReadonly;
5
+ export { CURRENT_META_VERSION, MAXIMUM_CACHE_TIME, defaultOptions };
6
+ //# sourceMappingURL=defaultOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultOptions.d.ts","sourceRoot":"","sources":["../../src/core/defaultOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,UAAU,CAAC;AAEvD,QAAA,MAAM,oBAAoB,IAAI,CAAC;AAC/B,QAAA,MAAM,kBAAkB,QAAqB,CAAC;AAE9C,QAAA,MAAM,cAAc,EAAE,2BASrB,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ const CURRENT_META_VERSION = 2;
2
+ const MAXIMUM_CACHE_TIME = 365 * 86400 * 1000;
3
+ const defaultOptions = {
4
+ // Public
5
+ maxCacheSize: 100,
6
+ maxCacheTime: 86400 * 1000,
7
+ // Development-only
8
+ warnIfItemPurgedBeforeTime: 5000,
9
+ // Private
10
+ opLimit: 200,
11
+ scanLimit: 50,
12
+ };
13
+ export { CURRENT_META_VERSION, MAXIMUM_CACHE_TIME, defaultOptions };
14
+ //# sourceMappingURL=defaultOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultOptions.js","sourceRoot":"","sources":["../../src/core/defaultOptions.ts"],"names":[],"mappings":"AAEA,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,kBAAkB,GAAG,GAAG,GAAG,KAAK,GAAG,IAAI,CAAC;AAE9C,MAAM,cAAc,GAAgC;IAClD,SAAS;IACT,YAAY,EAAE,GAAG;IACjB,YAAY,EAAE,KAAK,GAAG,IAAI;IAC1B,mBAAmB;IACnB,0BAA0B,EAAE,IAAI;IAChC,UAAU;IACV,OAAO,EAAE,GAAG;IACZ,SAAS,EAAE,EAAE;CACd,CAAC;AAEF,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,cAAc,EAAE,CAAC"}
@@ -1,12 +1,13 @@
1
- declare const limitedCacheUtil: {
2
- init: <ItemType = any>(optionsOrCacheMeta?: Partial<import("..").LimitedCacheOptionsFull> | import("..").LimitedCacheMeta<ItemType> | null | undefined) => import("..").LimitedCacheMeta<ItemType>;
3
- get: <ItemType_1 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_1>, cacheKey: string) => ItemType_1 | undefined;
4
- getAll: <ItemType_2 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_2>) => Record<string, ItemType_2>;
5
- has: <ItemType_3 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_3>, cacheKey: string) => boolean;
6
- set: <ItemType_4 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_4>, cacheKey: string, item: ItemType_4) => import("..").LimitedCacheMeta<ItemType_4>;
7
- remove: <ItemType_5 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_5>, cacheKey: string) => import("..").LimitedCacheMeta<ItemType_5>;
8
- reset: <ItemType_6 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_6>) => import("..").LimitedCacheMeta<ItemType_6>;
9
- doMaintenance: <ItemType_7 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_7>) => import("..").LimitedCacheMeta<ItemType_7>;
10
- setOptions: <ItemType_8 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_8>, options: import("..").LimitedCacheOptions) => Readonly<import("..").LimitedCacheOptionsFull>;
11
- };
12
- export { limitedCacheUtil };
1
+ declare const limitedCacheUtil: {
2
+ init: <ItemType = any>(optionsOrCacheMeta?: import("..").LimitedCacheOptions | import("..").LimitedCacheMeta<ItemType> | undefined) => import("..").LimitedCacheMeta<ItemType>;
3
+ get: <ItemType_1 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_1>, cacheKey: string) => ItemType_1 | undefined;
4
+ getAll: <ItemType_2 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_2>) => Record<string, ItemType_2>;
5
+ has: <ItemType_3 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_3>, cacheKey: string) => boolean;
6
+ set: <ItemType_4 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_4>, cacheKey: string, item: ItemType_4) => import("..").LimitedCacheMeta<ItemType_4>;
7
+ remove: <ItemType_5 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_5>, cacheKey: string) => import("..").LimitedCacheMeta<ItemType_5>;
8
+ reset: <ItemType_6 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_6>) => import("..").LimitedCacheMeta<ItemType_6>;
9
+ doMaintenance: <ItemType_7 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_7>) => import("..").LimitedCacheMeta<ItemType_7>;
10
+ setOptions: <ItemType_8 = any>(cacheMeta: import("..").LimitedCacheMeta<ItemType_8>, options: import("..").LimitedCacheOptions) => Readonly<import("..").LimitedCacheOptionsFull>;
11
+ };
12
+ export { limitedCacheUtil };
13
+ //# sourceMappingURL=limitedCacheUtil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limitedCacheUtil.d.ts","sourceRoot":"","sources":["../../src/core/limitedCacheUtil.ts"],"names":[],"mappings":"AAYA,QAAA,MAAM,gBAAgB;;;;;;;;;;CAUrB,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { lowLevelGetOne, lowLevelGetAll, lowLevelHas, lowLevelInit, lowLevelDoMaintenance, lowLevelRemove, lowLevelReset, lowLevelSet, lowLevelSetOptions, } from './lowLevelFunctions';
2
+ const limitedCacheUtil = {
3
+ init: lowLevelInit,
4
+ get: lowLevelGetOne,
5
+ getAll: lowLevelGetAll,
6
+ has: lowLevelHas,
7
+ set: lowLevelSet,
8
+ remove: lowLevelRemove,
9
+ reset: lowLevelReset,
10
+ doMaintenance: lowLevelDoMaintenance,
11
+ setOptions: lowLevelSetOptions,
12
+ };
13
+ export { limitedCacheUtil };
14
+ //# sourceMappingURL=limitedCacheUtil.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"limitedCacheUtil.js","sourceRoot":"","sources":["../../src/core/limitedCacheUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,WAAW,EACX,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,gBAAgB,GAAG;IACvB,IAAI,EAAE,YAAY;IAClB,GAAG,EAAE,cAAc;IACnB,MAAM,EAAE,cAAc;IACtB,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,WAAW;IAChB,MAAM,EAAE,cAAc;IACtB,KAAK,EAAE,aAAa;IACpB,aAAa,EAAE,qBAAqB;IACpC,UAAU,EAAE,kBAAkB;CAC/B,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -1,13 +1,14 @@
1
- import { LimitedCacheOptions, LimitedCacheOptionsReadonly, LimitedCacheMeta, LimitedCacheOptionsFull } from '../types';
2
- declare const isCacheMeta: (cacheMeta: LimitedCacheMeta) => boolean;
3
- declare const upgradeCacheMeta: (cacheMeta: LimitedCacheMeta) => void;
4
- declare const lowLevelSetOptions: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>, options: LimitedCacheOptions) => LimitedCacheOptionsReadonly;
5
- declare const lowLevelInit: <ItemType = any>(optionsOrCacheMeta?: Partial<LimitedCacheOptionsFull> | LimitedCacheMeta<ItemType> | null | undefined) => LimitedCacheMeta<ItemType>;
6
- declare const lowLevelDoMaintenance: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>) => LimitedCacheMeta<ItemType>;
7
- declare const lowLevelHas: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>, cacheKey: string) => boolean;
8
- declare const lowLevelGetOne: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>, cacheKey: string) => ItemType | undefined;
9
- declare const lowLevelGetAll: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>) => Record<string, ItemType>;
10
- declare const lowLevelSet: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>, cacheKey: string, item: ItemType) => LimitedCacheMeta<ItemType>;
11
- declare const lowLevelRemove: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>, cacheKey: string) => LimitedCacheMeta<ItemType>;
12
- declare const lowLevelReset: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>) => LimitedCacheMeta<ItemType>;
13
- export { isCacheMeta, upgradeCacheMeta, lowLevelInit, lowLevelGetOne, lowLevelGetAll, lowLevelHas, lowLevelSet, lowLevelRemove, lowLevelReset, lowLevelDoMaintenance, lowLevelSetOptions, };
1
+ import { LimitedCacheOptions, LimitedCacheOptionsReadonly, LimitedCacheMeta } from '../types';
2
+ declare const isCacheMeta: (cacheMeta: LimitedCacheMeta) => boolean;
3
+ declare const upgradeCacheMeta: (cacheMeta: LimitedCacheMeta) => void;
4
+ declare const lowLevelSetOptions: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>, options: LimitedCacheOptions) => LimitedCacheOptionsReadonly;
5
+ declare const lowLevelInit: <ItemType = any>(optionsOrCacheMeta?: LimitedCacheOptions | LimitedCacheMeta<ItemType> | undefined) => LimitedCacheMeta<ItemType>;
6
+ declare const lowLevelDoMaintenance: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>) => LimitedCacheMeta<ItemType>;
7
+ declare const lowLevelHas: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>, cacheKey: string) => boolean;
8
+ declare const lowLevelGetOne: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>, cacheKey: string) => ItemType | undefined;
9
+ declare const lowLevelGetAll: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>) => Record<string, ItemType>;
10
+ declare const lowLevelSet: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>, cacheKey: string, item: ItemType) => LimitedCacheMeta<ItemType>;
11
+ declare const lowLevelRemove: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>, cacheKey: string) => LimitedCacheMeta<ItemType>;
12
+ declare const lowLevelReset: <ItemType = any>(cacheMeta: LimitedCacheMeta<ItemType>) => LimitedCacheMeta<ItemType>;
13
+ export { isCacheMeta, upgradeCacheMeta, lowLevelInit, lowLevelGetOne, lowLevelGetAll, lowLevelHas, lowLevelSet, lowLevelRemove, lowLevelReset, lowLevelDoMaintenance, lowLevelSetOptions, };
14
+ //# sourceMappingURL=lowLevelFunctions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lowLevelFunctions.d.ts","sourceRoot":"","sources":["../../src/core/lowLevelFunctions.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,EAGjB,MAAM,UAAU,CAAC;AAqBlB,QAAA,MAAM,WAAW,cAAe,gBAAgB,KAAG,OAElD,CAAC;AAEF,QAAA,MAAM,gBAAgB,cAAe,gBAAgB,KAAG,IAWvD,CAAC;AAEF,QAAA,MAAM,kBAAkB,mEAEb,mBAAmB,KAC3B,2BAGF,CAAC;AAEF,QAAA,MAAM,YAAY,mIAkBjB,CAAC;AA0BF,QAAA,MAAM,qBAAqB,uFA+B1B,CAAC;AA4FF,QAAA,MAAM,WAAW,oEAEL,MAAM,KACf,OAWF,CAAC;AAEF,QAAA,MAAM,cAAc,oEAER,MAAM,yBAOjB,CAAC;AAEF,QAAA,MAAM,cAAc,qFAQnB,CAAC;AAEF,QAAA,MAAM,WAAW,oEAEL,MAAM,+CA+CjB,CAAC;AAEF,QAAA,MAAM,cAAc,oEAER,MAAM,+BAgBjB,CAAC;AAEF,QAAA,MAAM,aAAa,uFAUlB,CAAC;AAEF,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,WAAW,EACX,WAAW,EACX,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,kBAAkB,GACnB,CAAC"}