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

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

There is a newer version: 8.38.0
Show newest version
/** 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;
}

export { flatten };
//# sourceMappingURL=array.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy