(self: R, options?: {
readonly touch?: boolean | undefined
})
| 364 | * @since 4.0.0 |
| 365 | */ |
| 366 | export const waiting = <R extends AsyncResult<any, any>>(self: R, options?: { |
| 367 | readonly touch?: boolean | undefined |
| 368 | }): R => { |
| 369 | if (self.waiting) { |
| 370 | return options?.touch ? touch(self) : self |
| 371 | } |
| 372 | const result = Object.assign(Object.create(ResultProto), self) |
| 373 | result.waiting = true |
| 374 | if (options?.touch && isSuccess(result)) { |
| 375 | ;(result as any).timestamp = Date.now() |
| 376 | } |
| 377 | return result |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * Refreshes the timestamp of a `Success` result while preserving its value and waiting flag; non-success results are returned unchanged. |
no test coverage detected