Skip to content

Commit 7f8f50f

Browse files
committed
fixes
1 parent 5c1779d commit 7f8f50f

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/core/cache/default/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
/**
10-
* [[include:core/cache/simple/README.md]]
10+
* [[include:core/cache/default/README.md]]
1111
* @packageDocumentation
1212
*/
1313

@@ -44,4 +44,15 @@ export default class DefaultCache<K = unknown, V = unknown> extends SimpleCache<
4444

4545
return this.storage.get(key);
4646
}
47+
48+
/** @see [[Cache.clone]] */
49+
override clone(): DefaultCache<K, V> {
50+
const
51+
newCache = new DefaultCache<K, V>(this.defaultFactory),
52+
mixin = {storage: new Map(this.storage)};
53+
54+
Object.assign(newCache, mixin);
55+
56+
return newCache;
57+
}
4758
}

src/core/cache/default/spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import DefaultCache from 'core/cache/default';
1010

11-
describe('core/cache/simple', () => {
11+
describe('core/cache/default', () => {
1212
it('default value', () => {
1313
const
1414
cache = new DefaultCache(Array);
@@ -109,7 +109,7 @@ describe('core/cache/simple', () => {
109109

110110
it('`clones`', () => {
111111
const
112-
cache = new DefaultCache(),
112+
cache = new DefaultCache(() => 10),
113113
obj = {a: 1};
114114

115115
cache.set('foo', 1);

0 commit comments

Comments
 (0)