Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1a4c95e

Browse files
committed
generalize Lib.maxRowLength
- make it return z.length if z is 1D - make it return 0 when not an array
1 parent 660a546 commit 1a4c95e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/lib/array.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,14 @@ exports.concat = function() {
136136
exports.maxRowLength = function(z) {
137137
var len = 0;
138138

139-
for(var i = 0; i < z.length; i++) {
140-
len = Math.max(len, z[i].length);
139+
if(isArrayOrTypedArray(z)) {
140+
if(Array.isArray(z[0])) {
141+
for(var i = 0; i < z.length; i++) {
142+
len = Math.max(len, z[i].length);
143+
}
144+
} else {
145+
len = z.length;
146+
}
141147
}
142148

143149
return len;

0 commit comments

Comments
 (0)