Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: third_party/pkg/angular/lib/formatter/limit_to.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 part of angular.filter; 1 part of angular.formatter_internal;
2 2
3 /** 3 /**
4 * Creates a new List or String containing only a prefix/suffix of the 4 * Creates a new List or String containing only a prefix/suffix of the
5 * elements as specified by the `limit` parameter. 5 * elements as specified by the `limit` parameter.
6 * 6 *
7 * When operating on a List, the returned list is always a copy even when all 7 * When operating on a List, the returned list is always a copy even when all
8 * the elements are being returned. 8 * the elements are being returned.
9 * 9 *
10 * When the `limit` expression evaluates to a positive integer, `limit` items 10 * When the `limit` expression evaluates to a positive integer, `limit` items
11 * from the beginning of the List/String are returned. When `limit` evaluates 11 * from the beginning of the List/String are returned. When `limit` evaluates
(...skipping 15 matching lines...) Expand all
27 * 27 *
28 * This [ng-repeat] directive: 28 * This [ng-repeat] directive:
29 * 29 *
30 * <li ng-repeat="i in 'abcdefghij' | limitTo:-2">{{i}}</li> 30 * <li ng-repeat="i in 'abcdefghij' | limitTo:-2">{{i}}</li>
31 * 31 *
32 * results in 32 * results in
33 * 33 *
34 * <li>i</li> 34 * <li>i</li>
35 * <li>j</li> 35 * <li>j</li>
36 */ 36 */
37 @NgFilter(name:'limitTo') 37 @Formatter(name:'limitTo')
38 class LimitToFilter { 38 class LimitTo implements Function {
39 Injector _injector; 39 Injector _injector;
40 40
41 LimitToFilter(this._injector); 41 LimitTo(this._injector);
42 42
43 dynamic call(dynamic items, [int limit]) { 43 dynamic call(dynamic items, [int limit]) {
44 if (items == null) return null; 44 if (items == null) return null;
45 if (limit == null) return const[]; 45 if (limit == null) return const[];
46 if (items is! List && items is! String) return items; 46 if (items is! List && items is! String) return items;
47 int i = 0, j = items.length; 47 int i = 0, j = items.length;
48 if (limit > -1) { 48 if (limit > -1) {
49 j = (limit > j) ? j : limit; 49 j = (limit > j) ? j : limit;
50 } else { 50 } else {
51 i = j + limit; 51 i = j + limit;
52 if (i < 0) i = 0; 52 if (i < 0) i = 0;
53 } 53 }
54 return items is String ? 54 return items is String ?
55 (items as String).substring(i, j) : 55 (items as String).substring(i, j) :
56 (items as List).getRange(i, j).toList(growable: false); 56 (items as List).getRange(i, j).toList(growable: false);
57 } 57 }
58 } 58 }
OLDNEW
« no previous file with comments | « third_party/pkg/angular/lib/formatter/json.dart ('k') | third_party/pkg/angular/lib/formatter/lowercase.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698