lib/poet/methods.js
function scheduleFutures (poet, allPosts) {
  var now = Date.now();
  var extraTime = 5 * 1000; // 10 seconds buffer
  var min = now - extraTime;

  allPosts.forEach(function (post, i) {
    if (!post) return;
    var postTime = post.date.getTime();

    // if post is in the future
    if (postTime - min > 0) {
      // Prevent setTimeout overflow when scheduling more than 24 days out. See https://github.com/jsantell/poet/issues/119
      var delay = Math.min(postTime - min, Math.pow(2, 31) - 1);
      var future = setTimeout(function () {
        poet.watchers.forEach(function (watcher) {
          poet.init().then(watcher.callback);
        });
      }, delay);

      poet.futures.push(future);
    }
  });
}
function scheduleFutures (poet, allPosts) {
  var now = Date.now();
  var extraTime = 5 * 1000; // 10 seconds buffer
  var min = now - extraTime;

  allPosts.forEach(function (post, i) {
    if (!post) return;
    var postTime = post.date.getTime();

    // if post is in the future
    if (postTime - min > 0) {
      // Prevent setTimeout overflow when scheduling more than 24 days out. See https://github.com/jsantell/poet/issues/119
      var delay = Math.min(postTime - min, Math.pow(2, 31) - 1);
      var future = setTimeout(function () {
        poet.watchers.forEach(function (watcher) {
          poet.init().then(watcher.callback);
        });
      }, delay);

      poet.futures.push(future);
    }
  });
}
function scheduleFutures ( poet , allPosts ) { var now = Date . now ( ) ; var extraTime = 5 * 1000 ; // 10 seconds buffer var min = now - extraTime ; allPosts . forEach ( function ( post , i ) { if ( ! post ) return ; var postTime = post . date . getTime ( ) ; // if post is in the future if ( postTime - min > 0 ) { // Prevent setTimeout overflow when scheduling more than 24 days out. See https://github.com/jsantell/poet/issues/119 var delay = Math . min ( postTime - min , Math . pow ( 2 , 31 ) - 1 ) ; var future = setTimeout ( function ( ) { poet . watchers . forEach ( function ( watcher ) { poet . init ( ) . then ( watcher . callback ) ; } ) ; } , delay ) ; poet . futures . push ( future ) ; } } ) ; }
Schedules a watch event for all posts that are posted in a future date.
Schedules a watch event for all posts that are posted in a future date .