All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.build.cjs.array.js Maven / Gradle / Ivy

The newest version!
Object.defineProperty(exports, '__esModule', { value: true });

/** Flattens a multi-dimensional array */
function flatten(input) {
  const result = [];

  const flattenHelper = (input) => {
    input.forEach((el) => {
      if (Array.isArray(el)) {
        flattenHelper(el );
      } else {
        result.push(el );
      }
    });
  };

  flattenHelper(input);
  return result;
}

exports.flatten = flatten;
//# sourceMappingURL=array.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy