lib/mlutil.js
function asArray() {
  var argLen = arguments.length;
  switch(argLen) {
  // No arguments returns an empty array
  case 0:
    return [];
  // Single array argument returns that array
  case 1:
    var arg = arguments[0];
    if (Array.isArray(arg)) {
      return arg;
    }
    // Single object argument returns an array with object as only element
    return [arg];
  // List of arguments returns an array with arguments as elements
  default:
    var args = new Array(argLen);
    for(var i=0; i < argLen; ++i) {
      args[i] = arguments[i];
    }
    return args;
  }
}
function asArray() {
  var argLen = arguments.length;
  switch(argLen) {
  // No arguments returns an empty array
  case 0:
    return [];
  // Single array argument returns that array
  case 1:
    var arg = arguments[0];
    if (Array.isArray(arg)) {
      return arg;
    }
    // Single object argument returns an array with object as only element
    return [arg];
  // List of arguments returns an array with arguments as elements
  default:
    var args = new Array(argLen);
    for(var i=0; i < argLen; ++i) {
      args[i] = arguments[i];
    }
    return args;
  }
}
function asArray ( ) { var argLen = arguments . length ; switch ( argLen ) { // No arguments returns an empty array case 0 : return [ ] ; // Single array argument returns that array case 1 : var arg = arguments [ 0 ] ; if ( Array . isArray ( arg ) ) { return arg ; } // Single object argument returns an array with object as only element return [ arg ] ; // List of arguments returns an array with arguments as elements default : var args = new Array ( argLen ) ; for ( var i = 0 ; i < argLen ; ++ i ) { args [ i ] = arguments [ i ] ; } return args ; } }
Normalize arguments by returning them as an array.
Normalize arguments by returning them as an array .