Merge pull request #2864 from jmoenig/bh-reshape

reshape to no dimensions
snap7
Jens Mönig 2021-07-19 08:57:19 +02:00 zatwierdzone przez GitHub
commit b4d6761c63
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 9 dodań i 5 usunięć

Wyświetl plik

@ -687,11 +687,15 @@ List.prototype.reshape = function (dimensions) {
// answer a new list formatted to fit the given dimensions.
// truncate excess elements, if any.
// pad with (repetitions of) existing elements
var src = this.ravel().itemsArray(),
size = dimensions.isEmpty() ? 0
: dimensions.itemsArray().reduce((a, b) => a * b),
i = 0,
trg;
var size,
i = 0,
trg,
src = this.ravel().itemsArray();
// if no dimensions, report a scalar
if (dimensions.isEmpty()) return src[0];
size = dimensions.itemsArray().reduce((a, b) => a * b);
// make sure the items count matches the specified target dimensions
if (size < src.length) {