File size: 334 Bytes
776286d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /**
* A hook that keeps each input it is asked with, and answers, beside what
* it kept.
*
* @returns the hook, and each input in the order it came
*/
export function keeping<E>() {
const kept: E[] = []
function hook(_engine: unknown, e: E) {
kept.push(e)
return { value: undefined }
}
return { hook, kept }
}
|