Buckets:
| let weakMemoize = function <Arg extends object, Return>( | |
| func: (arg: Arg) => Return | |
| ): (arg: Arg) => Return { | |
| let cache = new WeakMap<Arg, Return>() | |
| return (arg: Arg) => { | |
| if (cache.has(arg)) { | |
| // Use non-null assertion because we just checked that the cache `has` it | |
| // This allows us to remove `undefined` from the return value | |
| return cache.get(arg)! | |
| } | |
| let ret = func(arg) | |
| cache.set(arg, ret) | |
| return ret | |
| } | |
| } | |
| export default weakMemoize | |
Xet Storage Details
- Size:
- 484 Bytes
- Xet hash:
- d406178aa52883fc5c9c6cc30f7e03bae219334515d1764922257392b9e0a095
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.