@fjell/cache 4.7.5 → 4.7.7

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 (112) hide show
  1. package/dist/Aggregator.d.ts +1 -0
  2. package/dist/Aggregator.d.ts.map +1 -0
  3. package/dist/Cache.d.ts +1 -0
  4. package/dist/Cache.d.ts.map +1 -0
  5. package/dist/CacheContext.d.ts +1 -0
  6. package/dist/CacheContext.d.ts.map +1 -0
  7. package/dist/CacheMap.d.ts +1 -0
  8. package/dist/CacheMap.d.ts.map +1 -0
  9. package/dist/CacheStats.d.ts +1 -0
  10. package/dist/CacheStats.d.ts.map +1 -0
  11. package/dist/Instance.d.ts +1 -0
  12. package/dist/Instance.d.ts.map +1 -0
  13. package/dist/InstanceFactory.d.ts +1 -0
  14. package/dist/InstanceFactory.d.ts.map +1 -0
  15. package/dist/Operations.d.ts +1 -0
  16. package/dist/Operations.d.ts.map +1 -0
  17. package/dist/Options.d.ts +1 -0
  18. package/dist/Options.d.ts.map +1 -0
  19. package/dist/Registry.d.ts +1 -0
  20. package/dist/Registry.d.ts.map +1 -0
  21. package/dist/browser/AsyncIndexDBCacheMap.d.ts +1 -0
  22. package/dist/browser/AsyncIndexDBCacheMap.d.ts.map +1 -0
  23. package/dist/browser/IndexDBCacheMap.d.ts +1 -0
  24. package/dist/browser/IndexDBCacheMap.d.ts.map +1 -0
  25. package/dist/browser/LocalStorageCacheMap.d.ts +1 -0
  26. package/dist/browser/LocalStorageCacheMap.d.ts.map +1 -0
  27. package/dist/browser/SessionStorageCacheMap.d.ts +1 -0
  28. package/dist/browser/SessionStorageCacheMap.d.ts.map +1 -0
  29. package/dist/events/CacheEventEmitter.d.ts +1 -0
  30. package/dist/events/CacheEventEmitter.d.ts.map +1 -0
  31. package/dist/events/CacheEventFactory.d.ts +1 -0
  32. package/dist/events/CacheEventFactory.d.ts.map +1 -0
  33. package/dist/events/CacheEventTypes.d.ts +1 -0
  34. package/dist/events/CacheEventTypes.d.ts.map +1 -0
  35. package/dist/events/index.d.ts +1 -0
  36. package/dist/events/index.d.ts.map +1 -0
  37. package/dist/eviction/EvictionManager.d.ts +1 -0
  38. package/dist/eviction/EvictionManager.d.ts.map +1 -0
  39. package/dist/eviction/EvictionStrategy.d.ts +1 -0
  40. package/dist/eviction/EvictionStrategy.d.ts.map +1 -0
  41. package/dist/eviction/EvictionStrategyConfig.d.ts +1 -0
  42. package/dist/eviction/EvictionStrategyConfig.d.ts.map +1 -0
  43. package/dist/eviction/EvictionStrategyFactory.d.ts +1 -0
  44. package/dist/eviction/EvictionStrategyFactory.d.ts.map +1 -0
  45. package/dist/eviction/EvictionStrategyValidation.d.ts +1 -0
  46. package/dist/eviction/EvictionStrategyValidation.d.ts.map +1 -0
  47. package/dist/eviction/index.d.ts +3 -1
  48. package/dist/eviction/index.d.ts.map +1 -0
  49. package/dist/eviction/strategies/ARCEvictionStrategy.d.ts +1 -0
  50. package/dist/eviction/strategies/ARCEvictionStrategy.d.ts.map +1 -0
  51. package/dist/eviction/strategies/FIFOEvictionStrategy.d.ts +1 -0
  52. package/dist/eviction/strategies/FIFOEvictionStrategy.d.ts.map +1 -0
  53. package/dist/eviction/strategies/LFUEvictionStrategy.d.ts +1 -0
  54. package/dist/eviction/strategies/LFUEvictionStrategy.d.ts.map +1 -0
  55. package/dist/eviction/strategies/LRUEvictionStrategy.d.ts +1 -0
  56. package/dist/eviction/strategies/LRUEvictionStrategy.d.ts.map +1 -0
  57. package/dist/eviction/strategies/MRUEvictionStrategy.d.ts +1 -0
  58. package/dist/eviction/strategies/MRUEvictionStrategy.d.ts.map +1 -0
  59. package/dist/eviction/strategies/RandomEvictionStrategy.d.ts +1 -0
  60. package/dist/eviction/strategies/RandomEvictionStrategy.d.ts.map +1 -0
  61. package/dist/eviction/strategies/TwoQueueEvictionStrategy.d.ts +1 -0
  62. package/dist/eviction/strategies/TwoQueueEvictionStrategy.d.ts.map +1 -0
  63. package/dist/index.d.ts +1 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +45 -5
  66. package/dist/logger.d.ts +2 -1
  67. package/dist/logger.d.ts.map +1 -0
  68. package/dist/memory/EnhancedMemoryCacheMap.d.ts +1 -0
  69. package/dist/memory/EnhancedMemoryCacheMap.d.ts.map +1 -0
  70. package/dist/memory/MemoryCacheMap.d.ts +1 -0
  71. package/dist/memory/MemoryCacheMap.d.ts.map +1 -0
  72. package/dist/normalization.d.ts +1 -0
  73. package/dist/normalization.d.ts.map +1 -0
  74. package/dist/ops/action.d.ts +1 -0
  75. package/dist/ops/action.d.ts.map +1 -0
  76. package/dist/ops/all.d.ts +2 -1
  77. package/dist/ops/all.d.ts.map +1 -0
  78. package/dist/ops/allAction.d.ts +2 -1
  79. package/dist/ops/allAction.d.ts.map +1 -0
  80. package/dist/ops/allFacet.d.ts +2 -1
  81. package/dist/ops/allFacet.d.ts.map +1 -0
  82. package/dist/ops/create.d.ts +2 -1
  83. package/dist/ops/create.d.ts.map +1 -0
  84. package/dist/ops/facet.d.ts +1 -0
  85. package/dist/ops/facet.d.ts.map +1 -0
  86. package/dist/ops/find.d.ts +2 -1
  87. package/dist/ops/find.d.ts.map +1 -0
  88. package/dist/ops/findOne.d.ts +2 -1
  89. package/dist/ops/findOne.d.ts.map +1 -0
  90. package/dist/ops/get.d.ts +1 -0
  91. package/dist/ops/get.d.ts.map +1 -0
  92. package/dist/ops/one.d.ts +2 -1
  93. package/dist/ops/one.d.ts.map +1 -0
  94. package/dist/ops/remove.d.ts +1 -0
  95. package/dist/ops/remove.d.ts.map +1 -0
  96. package/dist/ops/reset.d.ts +1 -0
  97. package/dist/ops/reset.d.ts.map +1 -0
  98. package/dist/ops/retrieve.d.ts +1 -0
  99. package/dist/ops/retrieve.d.ts.map +1 -0
  100. package/dist/ops/set.d.ts +1 -0
  101. package/dist/ops/set.d.ts.map +1 -0
  102. package/dist/ops/update.d.ts +1 -0
  103. package/dist/ops/update.d.ts.map +1 -0
  104. package/dist/ttl/TTLManager.d.ts +1 -0
  105. package/dist/ttl/TTLManager.d.ts.map +1 -0
  106. package/dist/ttl/index.d.ts +1 -0
  107. package/dist/ttl/index.d.ts.map +1 -0
  108. package/dist/utils/CacheSize.d.ts +1 -0
  109. package/dist/utils/CacheSize.d.ts.map +1 -0
  110. package/package.json +11 -6
  111. package/dist/index.js.map +0 -7
  112. package/fix-async-tests.js +0 -116
@@ -1,116 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- // List of async methods that need await
5
- const asyncMethods = [
6
- 'get',
7
- 'includesKey',
8
- 'values',
9
- 'allIn',
10
- 'contains',
11
- 'queryIn',
12
- 'clone',
13
- 'getQueryResult',
14
- 'invalidateLocation'
15
- ];
16
-
17
- // Function to fix async calls in a file
18
- function fixAsyncCalls(content) {
19
- let updatedContent = content;
20
-
21
- // First pass: Add await to all async method calls
22
- asyncMethods.forEach(method => {
23
- // Fix direct method calls that need await (but don't already have it)
24
- // Match cache variable names (cache, locCache, containedCache, cacheMap, etc.) but avoid things like mockLocalStorage.store
25
- const methodCallRegex = new RegExp(`(?<!await\\s)((cache|locCache|containedCache|cacheMap|cache1|cache2|complexCacheMap)\\s*\\.\\s*${method}\\s*\\([^)]*\\))`, 'g');
26
- updatedContent = updatedContent.replace(methodCallRegex, (match, methodCall) => {
27
- // Don't add await if it's already there
28
- return `await ${methodCall}`;
29
- });
30
-
31
- // Fix method calls in expect statements
32
- const expectRegex = new RegExp(`expect\\((?!await\\s)((cache|locCache|containedCache|cacheMap|cache1|cache2|complexCacheMap)\\s*\\.\\s*${method}\\s*\\([^)]*\\))\\)`, 'g');
33
- updatedContent = updatedContent.replace(expectRegex, 'expect(await $1)');
34
- });
35
-
36
- // Second pass: Find all it() functions that contain await and make them async
37
- const lines = updatedContent.split('\n');
38
- const updatedLines = [];
39
- let inTestFunction = false;
40
- let testFunctionStart = -1;
41
- let braceCount = 0;
42
- let hasAwait = false;
43
-
44
- for (let i = 0; i < lines.length; i++) {
45
- const line = lines[i];
46
-
47
- // Check if this line starts a test function
48
- const testMatch = line.match(/(\s*)(it\s*\(\s*['"][^'"]*['"],\s*)(\(\)\s*=>\s*\{)/);
49
- if (testMatch) {
50
- inTestFunction = true;
51
- testFunctionStart = i;
52
- braceCount = 1;
53
- hasAwait = false;
54
- updatedLines.push(line);
55
- continue;
56
- }
57
-
58
- if (inTestFunction) {
59
- // Count braces to track when we're out of the test function
60
- const openBraces = (line.match(/\{/g) || []).length;
61
- const closeBraces = (line.match(/\}/g) || []).length;
62
- braceCount += openBraces - closeBraces;
63
-
64
- // Check if this line contains await
65
- if (line.includes('await ')) {
66
- hasAwait = true;
67
- }
68
-
69
- // If we've closed all braces, we're done with this test function
70
- if (braceCount === 0) {
71
- inTestFunction = false;
72
-
73
- // If this test function contains await, make it async
74
- if (hasAwait) {
75
- const testLine = updatedLines[testFunctionStart];
76
- const testMatch = testLine.match(/(\s*)(it\s*\(\s*['"][^'"]*['"],\s*)(\(\)\s*=>\s*\{)/);
77
- if (testMatch && !testMatch[3].includes('async')) {
78
- updatedLines[testFunctionStart] = testMatch[1] + testMatch[2] + 'async () => {';
79
- }
80
- }
81
- }
82
- }
83
-
84
- updatedLines.push(line);
85
- }
86
-
87
- return updatedLines.join('\n');
88
- }
89
-
90
- // Process all browser cache test files
91
- const testFiles = [
92
- '/Users/tobrien/gitw/getfjell/fjell-cache/tests/browser/LocalStorageCacheMap.test.ts',
93
- '/Users/tobrien/gitw/getfjell/fjell-cache/tests/browser/SessionStorageCacheMap.test.ts',
94
- '/Users/tobrien/gitw/getfjell/fjell-cache/tests/browser/IndexDBCacheMap.test.ts',
95
- '/Users/tobrien/gitw/getfjell/fjell-cache/tests/browser/AsyncIndexDBCacheMap.test.ts'
96
- ];
97
-
98
- testFiles.forEach(testFile => {
99
- try {
100
- if (fs.existsSync(testFile)) {
101
- const content = fs.readFileSync(testFile, 'utf8');
102
- const fixedContent = fixAsyncCalls(content);
103
-
104
- if (content !== fixedContent) {
105
- fs.writeFileSync(testFile, fixedContent, 'utf8');
106
- console.log(`Fixed async calls in ${path.basename(testFile)}`);
107
- } else {
108
- console.log(`No changes needed in ${path.basename(testFile)}`);
109
- }
110
- } else {
111
- console.log(`File not found: ${testFile}`);
112
- }
113
- } catch (error) {
114
- console.error(`Error fixing file ${path.basename(testFile)}: ${error.message}`);
115
- }
116
- });