MCPcopy Index your code
hub / github.com/json-editor/json-editor / ensureArraySize

Method ensureArraySize

src/editors/array.js:337–349  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

335 }
336
337 ensureArraySize (value) {
338 if (!(Array.isArray(value))) value = [value]
339
340 if (this.schema.minItems) {
341 while (value.length < this.schema.minItems) {
342 value.push(this.getItemInfo(value.length).default)
343 }
344 }
345 if (this.getMax() && value.length > this.getMax()) {
346 value = value.slice(0, this.getMax())
347 }
348 return value
349 }
350
351 setValue (value = [], initial) {
352 value = this.applyConstFilter(value)

Callers 1

setValueMethod · 0.95

Calls 2

getItemInfoMethod · 0.95
getMaxMethod · 0.95

Tested by

no test coverage detected