lib/queue.js
function insert(queue, index, fns, mode = InsertMode.REGULAR) {
  fns.forEach(({ fn, name }) => {
    if (queue.findIndex(e => e.name === name) !== -1) {
      throw new Error(`${name}: A function is already queued with this name`);
    } else if (typeof fn !== 'function') {
      throw new Error(`${name}: Not a valid function`);
    }
  });

  const deleteCount = mode === InsertMode.REPLACE ? 1 : 0;
  queue.splice(index, deleteCount, ...fns);
}
function insert(queue, index, fns, mode = InsertMode.REGULAR) {
  fns.forEach(({ fn, name }) => {
    if (queue.findIndex(e => e.name === name) !== -1) {
      throw new Error(`${name}: A function is already queued with this name`);
    } else if (typeof fn !== 'function') {
      throw new Error(`${name}: Not a valid function`);
    }
  });

  const deleteCount = mode === InsertMode.REPLACE ? 1 : 0;
  queue.splice(index, deleteCount, ...fns);
}
function insert ( queue , index , fns , mode = InsertMode . REGULAR ) { fns . forEach ( ( { fn , name } ) => { if ( queue . findIndex ( e => e . name === name ) !== - 1 ) { throw new Error ( ` ${ name } ` ) ; } else if ( typeof fn !== 'function' ) { throw new Error ( ` ${ name } ` ) ; } } ) ; const deleteCount = mode === InsertMode . REPLACE ? 1 : 0 ; queue . splice ( index , deleteCount , ... fns ) ; }
Insert a bunch of functions into a queue at a given index.
Insert a bunch of functions into a queue at a given index .