typescript-lru-cache
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "typescript-lru-cache", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "LRU Cache", | ||
@@ -32,27 +32,37 @@ "author": "Robert Herber", | ||
"release": "np --no-cleanup --no-2fa", | ||
"build-circular-dependency-check": "madge --circular ./dist", | ||
"circular-dependency-check": "madge --circular --extensions ts --ts-config tsconfig.json ./src", | ||
"test": "jest --coverage", | ||
"test-watch": "jest --watchAll --coverage", | ||
"test-clean": "jest --clearCache", | ||
"version": "npm run build" | ||
"test-mutate": "npx stryker run", | ||
"typedoc": "rm -rf ./docs && typedoc src/index.ts", | ||
"version": "npm run build && npm run typedoc", | ||
"validate": "npm run build && npm run build-circular-dependency-check && npm t && npm run lint" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^12.0.1", | ||
"@commitlint/config-conventional": "^12.0.1", | ||
"@types/benchmark": "^2.1.0", | ||
"@types/jest": "^26.0.21", | ||
"@typescript-eslint/eslint-plugin": "^4.18.0", | ||
"@typescript-eslint/parser": "^4.18.0", | ||
"@commitlint/cli": "^13.1.0", | ||
"@commitlint/config-conventional": "^13.1.0", | ||
"@stryker-mutator/core": "^5.4.0", | ||
"@stryker-mutator/jest-runner": "^5.4.0", | ||
"@stryker-mutator/typescript-checker": "^5.4.0", | ||
"@types/benchmark": "^2.1.1", | ||
"@types/jest": "^27.0.2", | ||
"@typescript-eslint/eslint-plugin": "^4.31.2", | ||
"@typescript-eslint/parser": "^4.31.2", | ||
"benchmark": "^2.1.4", | ||
"eslint": "^7.22.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-jest": "^24.3.2", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"husky": "^4.3.8", | ||
"jest": "^26.6.3", | ||
"np": "^7.4.0", | ||
"prettier": "^2.2.1", | ||
"ts-jest": "^26.5.4", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.2.3" | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-jest": "^24.4.2", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"husky": "^7.0.2", | ||
"jest": "^27.2.2", | ||
"madge": "^5.0.1", | ||
"np": "^7.5.0", | ||
"prettier": "^2.4.1", | ||
"ts-jest": "^27.0.5", | ||
"ts-node": "^10.2.1", | ||
"typedoc": "^0.22.4", | ||
"typescript": "^4.4.3" | ||
} | ||
} |
@@ -41,2 +41,13 @@ # typescript-lru-cache | ||
```typescript | ||
export interface LRUCacheOptions<TKey, TValue> { | ||
maxSize?: number; | ||
entryExpirationTimeInMS?: number | null; | ||
onEntryEvicted?: (evictedEntry: { key: TKey; value: TValue; isExpired: boolean }) => void; | ||
onEntryMarkedAsMostRecentlyUsed?: (entry: { key: TKey; value: TValue }) => void; | ||
clone?: boolean; | ||
cloneFn?: (value: TValue) => TValue; | ||
} | ||
``` | ||
- `maxSize` The max number of items the cache can hold. Once the cache reaches this number, the least recently used entries will start to be evicted to make room for new entries. Defaults to 25. | ||
@@ -91,2 +102,12 @@ - `entryExpirationTimeInMS` The time to live for cache entries. Setting this to `null` will make entries never expire. Default value is `null`. | ||
```typescript | ||
export interface LRUCacheSetEntryOptions<TKey, TValue> { | ||
entryExpirationTimeInMS?: number | null; | ||
onEntryEvicted?: (evictedEntry: { key: TKey; value: TValue; isExpired: boolean }) => void; | ||
onEntryMarkedAsMostRecentlyUsed?: (entry: { key: TKey; value: TValue }) => void; | ||
clone?: boolean; | ||
cloneFn?: (value: TValue) => TValue; | ||
} | ||
``` | ||
- `entryExpirationTimeInMS` The time to live for the entry. Setting this to `null` will make the entry never expire. | ||
@@ -93,0 +114,0 @@ - `onEntryEvicted` Function to be called whenever _this_ entry is evicted from the cache (when evicted due to needing to make room, is expired, or deleted using delete()). Passed argument is an object: |
71394
385
23