@fjell/cache 4.7.6 → 4.7.8
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/Aggregator.d.ts +1 -0
- package/dist/Aggregator.d.ts.map +1 -0
- package/dist/Cache.d.ts +1 -0
- package/dist/Cache.d.ts.map +1 -0
- package/dist/CacheContext.d.ts +1 -0
- package/dist/CacheContext.d.ts.map +1 -0
- package/dist/CacheMap.d.ts +1 -0
- package/dist/CacheMap.d.ts.map +1 -0
- package/dist/CacheStats.d.ts +1 -0
- package/dist/CacheStats.d.ts.map +1 -0
- package/dist/Instance.d.ts +1 -0
- package/dist/Instance.d.ts.map +1 -0
- package/dist/InstanceFactory.d.ts +1 -0
- package/dist/InstanceFactory.d.ts.map +1 -0
- package/dist/Operations.d.ts +1 -0
- package/dist/Operations.d.ts.map +1 -0
- package/dist/Options.d.ts +1 -0
- package/dist/Options.d.ts.map +1 -0
- package/dist/Registry.d.ts +1 -0
- package/dist/Registry.d.ts.map +1 -0
- package/dist/browser/AsyncIndexDBCacheMap.d.ts +1 -0
- package/dist/browser/AsyncIndexDBCacheMap.d.ts.map +1 -0
- package/dist/browser/IndexDBCacheMap.d.ts +1 -0
- package/dist/browser/IndexDBCacheMap.d.ts.map +1 -0
- package/dist/browser/LocalStorageCacheMap.d.ts +1 -0
- package/dist/browser/LocalStorageCacheMap.d.ts.map +1 -0
- package/dist/browser/SessionStorageCacheMap.d.ts +1 -0
- package/dist/browser/SessionStorageCacheMap.d.ts.map +1 -0
- package/dist/events/CacheEventEmitter.d.ts +1 -0
- package/dist/events/CacheEventEmitter.d.ts.map +1 -0
- package/dist/events/CacheEventFactory.d.ts +1 -0
- package/dist/events/CacheEventFactory.d.ts.map +1 -0
- package/dist/events/CacheEventTypes.d.ts +1 -0
- package/dist/events/CacheEventTypes.d.ts.map +1 -0
- package/dist/events/index.d.ts +1 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/eviction/EvictionManager.d.ts +1 -0
- package/dist/eviction/EvictionManager.d.ts.map +1 -0
- package/dist/eviction/EvictionStrategy.d.ts +1 -0
- package/dist/eviction/EvictionStrategy.d.ts.map +1 -0
- package/dist/eviction/EvictionStrategyConfig.d.ts +1 -0
- package/dist/eviction/EvictionStrategyConfig.d.ts.map +1 -0
- package/dist/eviction/EvictionStrategyFactory.d.ts +1 -0
- package/dist/eviction/EvictionStrategyFactory.d.ts.map +1 -0
- package/dist/eviction/EvictionStrategyValidation.d.ts +1 -0
- package/dist/eviction/EvictionStrategyValidation.d.ts.map +1 -0
- package/dist/eviction/index.d.ts +3 -1
- package/dist/eviction/index.d.ts.map +1 -0
- package/dist/eviction/strategies/ARCEvictionStrategy.d.ts +1 -0
- package/dist/eviction/strategies/ARCEvictionStrategy.d.ts.map +1 -0
- package/dist/eviction/strategies/FIFOEvictionStrategy.d.ts +1 -0
- package/dist/eviction/strategies/FIFOEvictionStrategy.d.ts.map +1 -0
- package/dist/eviction/strategies/LFUEvictionStrategy.d.ts +1 -0
- package/dist/eviction/strategies/LFUEvictionStrategy.d.ts.map +1 -0
- package/dist/eviction/strategies/LRUEvictionStrategy.d.ts +1 -0
- package/dist/eviction/strategies/LRUEvictionStrategy.d.ts.map +1 -0
- package/dist/eviction/strategies/MRUEvictionStrategy.d.ts +1 -0
- package/dist/eviction/strategies/MRUEvictionStrategy.d.ts.map +1 -0
- package/dist/eviction/strategies/RandomEvictionStrategy.d.ts +1 -0
- package/dist/eviction/strategies/RandomEvictionStrategy.d.ts.map +1 -0
- package/dist/eviction/strategies/TwoQueueEvictionStrategy.d.ts +1 -0
- package/dist/eviction/strategies/TwoQueueEvictionStrategy.d.ts.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -3
- package/dist/logger.d.ts +1 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/memory/EnhancedMemoryCacheMap.d.ts +1 -0
- package/dist/memory/EnhancedMemoryCacheMap.d.ts.map +1 -0
- package/dist/memory/MemoryCacheMap.d.ts +1 -0
- package/dist/memory/MemoryCacheMap.d.ts.map +1 -0
- package/dist/normalization.d.ts +1 -0
- package/dist/normalization.d.ts.map +1 -0
- package/dist/ops/action.d.ts +1 -0
- package/dist/ops/action.d.ts.map +1 -0
- package/dist/ops/all.d.ts +1 -0
- package/dist/ops/all.d.ts.map +1 -0
- package/dist/ops/allAction.d.ts +1 -0
- package/dist/ops/allAction.d.ts.map +1 -0
- package/dist/ops/allFacet.d.ts +1 -0
- package/dist/ops/allFacet.d.ts.map +1 -0
- package/dist/ops/create.d.ts +1 -0
- package/dist/ops/create.d.ts.map +1 -0
- package/dist/ops/facet.d.ts +1 -0
- package/dist/ops/facet.d.ts.map +1 -0
- package/dist/ops/find.d.ts +1 -0
- package/dist/ops/find.d.ts.map +1 -0
- package/dist/ops/findOne.d.ts +1 -0
- package/dist/ops/findOne.d.ts.map +1 -0
- package/dist/ops/get.d.ts +1 -0
- package/dist/ops/get.d.ts.map +1 -0
- package/dist/ops/one.d.ts +1 -0
- package/dist/ops/one.d.ts.map +1 -0
- package/dist/ops/remove.d.ts +1 -0
- package/dist/ops/remove.d.ts.map +1 -0
- package/dist/ops/reset.d.ts +1 -0
- package/dist/ops/reset.d.ts.map +1 -0
- package/dist/ops/retrieve.d.ts +1 -0
- package/dist/ops/retrieve.d.ts.map +1 -0
- package/dist/ops/set.d.ts +1 -0
- package/dist/ops/set.d.ts.map +1 -0
- package/dist/ops/update.d.ts +1 -0
- package/dist/ops/update.d.ts.map +1 -0
- package/dist/ttl/TTLManager.d.ts +1 -0
- package/dist/ttl/TTLManager.d.ts.map +1 -0
- package/dist/ttl/index.d.ts +1 -0
- package/dist/ttl/index.d.ts.map +1 -0
- package/dist/utils/CacheSize.d.ts +1 -0
- package/dist/utils/CacheSize.d.ts.map +1 -0
- package/package.json +13 -8
- package/dist/index.js.map +0 -7
- package/fix-async-tests.js +0 -116
package/fix-async-tests.js
DELETED
|
@@ -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
|
-
});
|