$([1,2,3,4,5]).first(3) -> [1,2,3]
$([1, 2, 3]).reduce((sum, num) => sum + num, 0) -> 6
Mixin.mixin({
'myReverse': (string) => $( $(string.splitChars() ).reverse()).join('')
});
$("test").myReverse() -> tset
class MyListExtensions extends List$ {
MyListExtensions(target) : super(target);
double avg() => sum() / target.length;
int count(predicate) => filter(predicate).length;
}
Mixin.registerFactory((x) => x is List ? new MyListExtensions(x) : null);
$([20,30,50,100]).count() -> 4
$([20,30,50,100]).avg() -> 50
> $([1,2,3,4,5]).first(3)..sum()
I'm already able to do this without cascades in Dart Query ( https://github.com/Ladicek/dart-query), which is a collection library not unlike Underscore.
Having every operation return new wrapper allows doing the work lazily, which is a big win (not that it wouldn't be possible with a single wrapper only, using some kind of operation queue, but that's way more involved).
LT
Using cascades, you'll be able to do this:
$([1,2,3,4,5]).first(3)..sum()
I'm already able to do this without cascades in Dart Query ( https://github.com/Ladicek/dart-query), which is a collection library not unlike Underscore.
I'm working on my own 'LINQ to Dart' implementation and at first sight it looks dauntingly similar to your library. Thank you, I look like a shameless copycat now :).
I'm already able to do this without cascades in Dart Query ( https://github.com/Ladicek/dart-query), which is a collection library not unlike Underscore.I'm working on my own 'LINQ to Dart' implementation and at first sight it looks dauntingly similar to your library. Thank you, I look like a shameless copycat now :).