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

Commit 2caec44

Browse files
shahatapetebacondarwin
authored andcommitted
refactor(limitTo): no need for all those checks if we use slice
Closes #10537
1 parent eae848a commit 2caec44

File tree

1 file changed

+4
-27
lines changed

1 file changed

+4
-27
lines changed

src/ng/filter/limitTo.js

+4-27
Original file line numberDiff line numberDiff line change
@@ -97,34 +97,11 @@ function limitToFilter() {
9797
limit = int(limit);
9898
}
9999

100-
if (isString(input)) {
101-
//NaN check on limit
102-
if (limit) {
103-
return limit >= 0 ? input.slice(0, limit) : input.slice(limit, input.length);
104-
} else {
105-
return "";
106-
}
107-
}
108-
109-
var i, n;
110-
111-
// if abs(limit) exceeds maximum length, trim it
112-
if (limit > input.length)
113-
limit = input.length;
114-
else if (limit < -input.length)
115-
limit = -input.length;
116-
117-
if (limit > 0) {
118-
i = 0;
119-
n = limit;
100+
//NaN check on limit
101+
if (limit) {
102+
return limit > 0 ? input.slice(0, limit) : input.slice(limit);
120103
} else {
121-
// zero and NaN check on limit - return empty array
122-
if (!limit) return [];
123-
124-
i = input.length + limit;
125-
n = input.length;
104+
return isString(input) ? "" : [];
126105
}
127-
128-
return input.slice(i, n);
129106
};
130107
}

0 commit comments

Comments
 (0)