MCPcopy Index your code
hub / github.com/autoNumeric/autoNumeric / arrayTrim

Method arrayTrim

src/AutoNumericHelper.js:1464–1478  ·  view source on GitHub ↗

* Return the given array trimmed to the given length. The original array is also trimmed. * @example arrayTrim([1, 2, 3, 4], 2) -> [1, 2] * * @param {Array} array * @param {Number} length * @returns {Array}

(array, length)

Source from the content-addressed store, hash-verified

1462 * @returns {Array}
1463 */
1464 static arrayTrim(array, length) {
1465 const arrLength = array.length;
1466 if (arrLength === 0 || length > arrLength) {
1467 // Also manage the case where `length` is higher than the current length
1468 return array;
1469 }
1470
1471 if (length < 0) {
1472 return [];
1473 }
1474
1475 array.length = parseInt(length, 10);
1476
1477 return array;
1478 }
1479
1480 /**
1481 * Merge all the given arrays by keeping only unique elements, and return an array with de-duplicated values.

Callers 1

_historyTableAddMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected