MCPcopy Create free account
hub / github.com/josdejong/mathjs / formatArray

Function formatArray

src/utils/string.js:169–184  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

167 * @returns {string} str
168 */
169function 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)

Callers 1

_formatFunction · 0.85

Calls 1

formatFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…