lib/Master.js
/**
 * Flattens a slave list down to an array of slaves.
 * So if an array is encountered, it's elements will simply be added to the slave list.
 * @param {Boolean} strict If true, this will throw when it encounters a non-Slave argument.
 * @param {...Slave|Array} slaveList The list of slaves to flatten.
 * @return {Array<Slaves>} The flattened list of slaves.
 */
Flattens a slave list down to an array of slaves.
So if an array is encountered, it's elements will simply be added to the slave list.
@param {Boolean} strict If true, this will throw when it encounters a non-Slave argument.
@param {...Slave|Array} slaveList The list of slaves to flatten.
@return {Array} The flattened list of slaves.
Flattens a slave list down to an array of slaves . So if an array is encountered it ' s elements will simply be added to the slave list . @param { Boolean } strict If true this will throw when it encounters a non - Slave argument . @param { ... Slave|Array } slaveList The list of slaves to flatten . @return { Array } The flattened list of slaves .
function flattenSlaveList(strict, ...slaveList) {
  let slaves = [];
  slaveList._.every(function buildSlaveList(slaveOrGroup) {
    if (slaveOrGroup instanceof Array) return slaveOrGroup._.every(buildSlaveList);
    const slaveGroup = Slave.getSlavesInGroup(slaveOrGroup);
    const s = slaveGroup.length > 0 ? slaveGroup : Slave.getSlave(slaveOrGroup);
    if (s instanceof Array) {
      slaves = slaves.concat(s);
    } else if (s) {
      slaves.push(s);
    } else if (strict) {
      throw new TypeError(
        `Expected an instanceof Slave, slave id, group id, or slave alias, but got "${slaveOrGroup}".`
      );
    }
    return true;
  });
  return slaves;
}
function flattenSlaveList ( strict , ... slaveList ) { let slaves = [ ] ; slaveList . _ . every ( function buildSlaveList ( slaveOrGroup ) { if ( slaveOrGroup instanceof Array ) return slaveOrGroup . _ . every ( buildSlaveList ) ; const slaveGroup = Slave . getSlavesInGroup ( slaveOrGroup ) ; const s = slaveGroup . length > 0 ? slaveGroup : Slave . getSlave ( slaveOrGroup ) ; if ( s instanceof Array ) { slaves = slaves . concat ( s ) ; } else if ( s ) { slaves . push ( s ) ; } else if ( strict ) { throw new TypeError ( ` ${ slaveOrGroup } ` ) ; } return true ; } ) ; return slaves ; }
Flattens a slave list down to an array of slaves.
Flattens a slave list down to an array of slaves .