src/index.js
function splitArgsIntoOptionsAndCallback (args) {
  let params;
  let options;
  let cb;
  if (args.length > 1) {
    const possibleCb = args[args.length - 1];
    if ('function' === typeof possibleCb) {
      cb = possibleCb;
      options = args.length === 3 ? args[1] : undefined;
    } else {
      options = args[1];
    }
    params = args[0];
  } else if ('object' === typeof args[0]) {
    params = args[0];
  } else if ('function' === typeof args[0]) {
    cb = args[0];
  }
  return { params, options, cb };
}
function splitArgsIntoOptionsAndCallback (args) {
  let params;
  let options;
  let cb;
  if (args.length > 1) {
    const possibleCb = args[args.length - 1];
    if ('function' === typeof possibleCb) {
      cb = possibleCb;
      options = args.length === 3 ? args[1] : undefined;
    } else {
      options = args[1];
    }
    params = args[0];
  } else if ('object' === typeof args[0]) {
    params = args[0];
  } else if ('function' === typeof args[0]) {
    cb = args[0];
  }
  return { params, options, cb };
}
function splitArgsIntoOptionsAndCallback ( args ) { let params ; let options ; let cb ; if ( args . length > 1 ) { const possibleCb = args [ args . length - 1 ] ; if ( 'function' === typeof possibleCb ) { cb = possibleCb ; options = args . length === 3 ? args [ 1 ] : undefined ; } else { options = args [ 1 ] ; } params = args [ 0 ] ; } else if ( 'object' === typeof args [ 0 ] ) { params = args [ 0 ] ; } else if ( 'function' === typeof args [ 0 ] ) { cb = args [ 0 ] ; } return { params , options , cb } ; }
Takes a variable-length array that represents arguments to a function and attempts to split it into
an 'options' object and a 'cb' callback function.
@param {Array}   args The arguments to the function
@return {Object}
Takes a variable - length array that represents arguments to a function and attempts to split it into an options object and a cb callback function .