UNPKG

substance

Version:

Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing system. It is developed to power our online editing platform [Substance](http://substance.io).

15 lines (13 loc) 325 B
import flatten from './flatten' export default function flattenOften (arr, max) { if (!(max > 0)) throw new Error("'max' must be a positive number") let l = arr.length arr = flatten(arr) let round = 1 while (round < max && l < arr.length) { l = arr.length arr = flatten(arr) round++ } return arr }