Skip to content

Commit

Permalink
make some params optional / fix some docs / add alias for delAll()
Browse files Browse the repository at this point in the history
  • Loading branch information
vinikjkkj committed Sep 15, 2024
1 parent 5d05c69 commit 1b9a1bc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cachetools-js",
"version": "1.0.0",
"version": "1.0.1",
"description": "Best, faster, ligther, all-in-one, fully-typed cache library for JS, based on cachetools from python, with events, pooling and decorators.",
"author": "vinikjkkj",
"license": "MIT",
Expand Down
11 changes: 5 additions & 6 deletions src/caches/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ import { CacheParams, Keyable } from '../types'
*
* //get 'bar' key
* cache['bar']
*
* //try to store another key
* cache['baz'] = 'foo'
* //throws SizeError, you need to delete some key to store another key
*
* ```
*/
export class Cache extends CacheEmitter {
Expand All @@ -35,7 +30,7 @@ export class Cache extends CacheEmitter {
/**
* Creates a new Cache.
*/
constructor(params: CacheParams){
constructor(params: CacheParams = {}){
super()
this._cache = new Map()
this._params = params
Expand Down Expand Up @@ -90,6 +85,10 @@ export class Cache extends CacheEmitter {
this._cache.delete(key)
}

flushAll(){
this.delAll()
}

delAll(){
this._cache.clear()
}
Expand Down
2 changes: 1 addition & 1 deletion src/caches/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class CachePool extends CachePoolEmitter {

[key: string | symbol]: unknown

constructor(params: CachePoolParams){
constructor(params: CachePoolParams = {}){
super()
this._caches = new Map()
this._params = params
Expand Down
2 changes: 1 addition & 1 deletion src/caches/ttl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class TTLCache extends Cache {
/**
* Creates a new TTLCache.
*/
constructor(params: TTLParams){
constructor(params: TTLParams = {}){
super({
maxsize: params.maxsize,
useClones: params.useClones
Expand Down

0 comments on commit 1b9a1bc

Please sign in to comment.