All files after.ts

12.5% Statements 1/8
100% Branches 0/0
0% Functions 0/3
16.66% Lines 1/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 103x                  
import { Channel } from './channel.js'
 
/** @returns channel that closes after specified time in milliseconds. */
export function after<T = unknown>(milliseconds: number) {
  const ch = new Channel<T>()
  const timeoutId = setTimeout(() => ch.closeWriting(), milliseconds)
  ch.onceDoneWriting(() => clearTimeout(timeoutId))
  return ch
}