flatten.js 268 Bytes Edit Raw Blame History 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 'use strict'; var isArray = Array.isArray, forEach = Array.prototype.forEach; module.exports = function flatten() { var r = []; forEach.call(this, function (x) { if (isArray(x)) { r = r.concat(flatten.call(x)); } else { r.push(x); } }); return r; };