'use strict';

var timer = require('./timer.js');

function timeout(callback, delay, time) {
  var t = new timer.Timer;
  delay = delay == null ? 0 : +delay;
  t.restart(elapsed => {
    t.stop();
    callback(elapsed + delay);
  }, delay, time);
  return t;
}

module.exports = timeout;
