(fn)
| 21 | } |
| 22 | |
| 23 | function memoize(fn) { |
| 24 | const cache = {}; |
| 25 | function wrapped(...args) { |
| 26 | const key = args.toString(); |
| 27 | let result = cache[key]; |
| 28 | if (!result) { |
| 29 | result = { data: fn(...args) }; |
| 30 | cache[key] = result; |
| 31 | } |
| 32 | return result.data; |
| 33 | } |
| 34 | return wrapped; |
| 35 | } |
| 36 | |
| 37 | function limitConcurrency(fn, concurrency) { |
| 38 | const tokens = []; |