* Recursively format an n-dimensional matrix * Example output: "[[1, 2], [3, 4]]" * @param {Array} array * @param {Object | number | Function} [options] Formatting options. See * lib/utils/number:format for a *
(array, options)
| 167 | * @returns {string} str |
| 168 | */ |
| 169 | function formatArray (array, options) { |
| 170 | if (Array.isArray(array)) { |
| 171 | let str = '[' |
| 172 | const len = array.length |
| 173 | for (let i = 0; i < len; i++) { |
| 174 | if (i !== 0) { |
| 175 | str += ', ' |
| 176 | } |
| 177 | str += formatArray(array[i], options) |
| 178 | } |
| 179 | str += ']' |
| 180 | return str |
| 181 | } else { |
| 182 | return format(array, options) |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Check whether a value looks like a Fraction (unsafe duck-type check) |