array-flatten.js
function flattenDownDepth (array, result, depth) {
  depth--

  for (var i = 0; i < array.length; i++) {
    var value = array[i]

    if (depth > -1 && Array.isArray(value)) {
      flattenDownDepth(value, result, depth)
    } else {
      result.push(value)
    }
  }

  return result
}
function flattenDownDepth (array, result, depth) {
  depth--

  for (var i = 0; i < array.length; i++) {
    var value = array[i]

    if (depth > -1 && Array.isArray(value)) {
      flattenDownDepth(value, result, depth)
    } else {
      result.push(value)
    }
  }

  return result
}
function flattenDownDepth ( array , result , depth ) { depth -- for ( var i = 0 ; i < array . length ; i ++ ) { var value = array [ i ] if ( depth > - 1 && Array . isArray ( value ) ) { flattenDownDepth ( value , result , depth ) } else { result . push ( value ) } } return result }
Flatten an array with depth.

@param  {Array}  array
@param  {Array}  result
@param  {number} depth
@return {Array}
Flatten an array with depth .