(mapping)
| 437 | |
| 438 | class Cached { |
| 439 | constructor(mapping) { |
| 440 | this.mapping = mapping |
| 441 | this.work = Object.create(null) |
| 442 | this.done = Object.create(null) |
| 443 | } |
| 444 | |
| 445 | compute(value) { |
| 446 | return this.work[value] || (this.work[value] = this.mapping(value).then(result => this.done[value] = result)) |