flatten.js 613 B

12345678910111213141516171819202122232425
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.flatten = flatten;
  6. function flatten(list) {
  7. let jlen, j, value, idx = 0, result = [];
  8. while(idx < list.length){
  9. if (Array.isArray(list[idx])) {
  10. value = flatten(list[idx]);
  11. j = 0;
  12. jlen = value.length;
  13. while(j < jlen){
  14. result[result.length] = value[j];
  15. j += 1;
  16. }
  17. } else {
  18. result[result.length] = list[idx];
  19. }
  20. idx += 1;
  21. }
  22. return result;
  23. }
  24. //# sourceMappingURL=flatten.js.map