You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
349 B

3 months ago
  1. 'use strict';
  2. const internals = {};
  3. module.exports = internals.flatten = function (array, target) {
  4. const result = target || [];
  5. for (const entry of array) {
  6. if (Array.isArray(entry)) {
  7. internals.flatten(entry, result);
  8. }
  9. else {
  10. result.push(entry);
  11. }
  12. }
  13. return result;
  14. };