Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit d232151

Browse files
refactor(limitTo): no need for all those checks if we use slice
Closes #10537
1 parent 8d6c594 commit d232151

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

src/ng/filter/limitTo.js

+4-29
Original file line numberDiff line numberDiff line change
@@ -81,36 +81,11 @@ function limitToFilter(){
8181
limit = int(limit);
8282
}
8383

84-
if (isString(input)) {
85-
//NaN check on limit
86-
if (limit) {
87-
return limit >= 0 ? input.slice(0, limit) : input.slice(limit, input.length);
88-
} else {
89-
return "";
90-
}
91-
}
92-
93-
var out = [],
94-
i, n;
95-
96-
// if abs(limit) exceeds maximum length, trim it
97-
if (limit > input.length)
98-
limit = input.length;
99-
else if (limit < -input.length)
100-
limit = -input.length;
101-
102-
if (limit > 0) {
103-
i = 0;
104-
n = limit;
84+
//NaN check on limit
85+
if (limit) {
86+
return limit > 0 ? input.slice(0, limit) : input.slice(limit);
10587
} else {
106-
i = input.length + limit;
107-
n = input.length;
88+
return isString(input) ? "" : [];
10889
}
109-
110-
for (; i<n; i++) {
111-
out.push(input[i]);
112-
}
113-
114-
return out;
11590
};
11691
}

0 commit comments

Comments
 (0)