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

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

The 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