index.js 418 B

12345678910111213141516171819202122
  1. /*!
  2. * arr-flatten <https://github.com/jonschlinkert/arr-flatten>
  3. *
  4. * Copyright (c) 2014-2017, Jon Schlinkert.
  5. * Released under the MIT License.
  6. */
  7. 'use strict';
  8. module.exports = function (arr) {
  9. return flat(arr, []);
  10. };
  11. function flat(arr, res) {
  12. var i = 0, cur;
  13. var len = arr.length;
  14. for (; i < len; i++) {
  15. cur = arr[i];
  16. Array.isArray(cur) ? flat(cur, res) : res.push(cur);
  17. }
  18. return res;
  19. }