mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:31:50 +00:00
Add Iterable.fold (and Stream.fold) which replace reduce
.
For now this is just a copy. In a next step we will change the behavior of `reduce`. BUG= http://dartbug.com/9536 Review URL: https://codereview.chromium.org//13548002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@20978 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
613746189b
commit
bef8ebb5f6
|
@ -23,7 +23,7 @@ class ByteStream extends StreamView<List<int>> {
|
|||
/// Collects the data of this stream in a [Uint8List].
|
||||
Future<Uint8List> toBytes() {
|
||||
/// TODO(nweiz): use BufferList when issue 6409 is fixed.
|
||||
return reduce(<int>[], (buffer, chunk) {
|
||||
return fold(<int>[], (buffer, chunk) {
|
||||
buffer.addAll(chunk);
|
||||
return buffer;
|
||||
}).then(toUint8List);
|
||||
|
|
|
@ -32,7 +32,7 @@ void scheduleSandbox() {
|
|||
}
|
||||
|
||||
Future<List<int>> byteStreamToList(Stream<List<int>> stream) {
|
||||
return stream.reduce(<int>[], (buffer, chunk) {
|
||||
return stream.fold(<int>[], (buffer, chunk) {
|
||||
buffer.addAll(chunk);
|
||||
return buffer;
|
||||
});
|
||||
|
|
|
@ -300,7 +300,7 @@ Future<ProcessResult> _runNonInteractiveProcess(String path,
|
|||
// Setup stdout handling.
|
||||
Future<StringBuffer> stdout = p.stdout
|
||||
.transform(new StringDecoder(stdoutEncoding))
|
||||
.reduce(
|
||||
.fold(
|
||||
new StringBuffer(),
|
||||
(buf, data) {
|
||||
buf.write(data);
|
||||
|
@ -309,7 +309,7 @@ Future<ProcessResult> _runNonInteractiveProcess(String path,
|
|||
|
||||
Future<StringBuffer> stderr = p.stderr
|
||||
.transform(new StringDecoder(stderrEncoding))
|
||||
.reduce(
|
||||
.fold(
|
||||
new StringBuffer(),
|
||||
(buf, data) {
|
||||
buf.write(data);
|
||||
|
|
|
@ -220,6 +220,6 @@ class Sample {
|
|||
Iterator<int> get iterator => _segments.iterator;
|
||||
|
||||
int total() {
|
||||
return _segments.reduce(0, (int prev, int element) => prev + element);
|
||||
return _segments.fold(0, (int prev, int element) => prev + element);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -118,6 +118,10 @@ class _ObjectArray<E> implements List<E> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
fold(initialValue, combine(previousValue, E element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
Iterable<E> where(bool f(E element)) {
|
||||
return IterableMixinWorkaround.where(this, f);
|
||||
}
|
||||
|
@ -361,6 +365,10 @@ class _ImmutableArray<E> implements List<E> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
fold(initialValue, combine(previousValue, E element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
Iterable<E> where(bool f(E element)) {
|
||||
return IterableMixinWorkaround.where(this, f);
|
||||
}
|
||||
|
|
|
@ -268,6 +268,10 @@ class _GrowableObjectArray<T> implements List<T> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
fold(initialValue, combine(previousValue, T element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
Iterable<T> where(bool f(T element)) {
|
||||
return IterableMixinWorkaround.where(this, f);
|
||||
}
|
||||
|
|
|
@ -312,6 +312,11 @@ abstract class _TypedListBase {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic initialValue, element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
Iterable where(bool f(int element)) {
|
||||
return IterableMixinWorkaround.where(this, f);
|
||||
}
|
||||
|
|
|
@ -200,6 +200,10 @@ abstract class ListIterable<E> extends Iterable<E> {
|
|||
Iterable map(f(E element)) => new MappedListIterable(this, f);
|
||||
|
||||
reduce(var initialValue, combine(var previousValue, E element)) {
|
||||
return fold(initialValue, combine);
|
||||
}
|
||||
|
||||
fold(var initialValue, combine(var previousValue, E element)) {
|
||||
var value = initialValue;
|
||||
int length = this.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
@ -670,6 +674,10 @@ class EmptyIterable<E> extends Iterable<E> {
|
|||
Iterable map(f(E element)) => const EmptyIterable();
|
||||
|
||||
reduce(var initialValue, combine(var previousValue, E element)) {
|
||||
return fold(initialValue, combine);
|
||||
}
|
||||
|
||||
fold(var initialValue, combine(var previousValue, E element)) {
|
||||
return initialValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -207,6 +207,10 @@ abstract class ListMixin<E> implements List<E> {
|
|||
Iterable map(f(E element)) => new MappedListIterable(this, f);
|
||||
|
||||
reduce(var initialValue, combine(var previousValue, E element)) {
|
||||
return fold(initialValue, combine);
|
||||
}
|
||||
|
||||
fold(var initialValue, combine(var previousValue, E element)) {
|
||||
var value = initialValue;
|
||||
int length = this.length;
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
|
|
@ -125,6 +125,10 @@ class JSArray<E> extends Interceptor implements List<E>, JSIndexable {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
fold(initialValue, combine(previousValue, E element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
E firstWhere(bool test(E value), {E orElse()}) {
|
||||
return IterableMixinWorkaround.firstWhere(this, test, orElse);
|
||||
}
|
||||
|
|
|
@ -249,8 +249,18 @@ abstract class Stream<T> {
|
|||
return streamTransformer.bind(this);
|
||||
}
|
||||
|
||||
/** Reduces a sequence of values by repeatedly applying [combine]. */
|
||||
/**
|
||||
* Reduces a sequence of values by repeatedly applying [combine].
|
||||
*
|
||||
* *WARNING UPCOMING API-CHANGE*: This method will be changed so that
|
||||
* it doesn't take an initial value. Use [fold] instead.
|
||||
*/
|
||||
Future reduce(var initialValue, combine(var previous, T element)) {
|
||||
return fold(initialValue, combine);
|
||||
}
|
||||
|
||||
/** Reduces a sequence of values by repeatedly applying [combine]. */
|
||||
Future fold(var initialValue, combine(var previous, T element)) {
|
||||
_FutureImpl result = new _FutureImpl();
|
||||
var value = initialValue;
|
||||
StreamSubscription subscription;
|
||||
|
|
|
@ -40,6 +40,12 @@ class IterableMixinWorkaround {
|
|||
static dynamic reduce(Iterable iterable,
|
||||
dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, element)) {
|
||||
return fold(iterable, initialValue, combine);
|
||||
}
|
||||
|
||||
static dynamic fold(Iterable iterable,
|
||||
dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, element)) {
|
||||
for (final element in iterable) {
|
||||
initialValue = combine(initialValue, element);
|
||||
}
|
||||
|
|
|
@ -98,12 +98,31 @@ abstract class Iterable<E> {
|
|||
* Use [initialValue] as the initial value, and the function [combine] to
|
||||
* create a new value from the previous one and an element.
|
||||
*
|
||||
* Example of calculating the sum of a collection:
|
||||
* Example of calculating the sum of an iterable:
|
||||
*
|
||||
* collection.reduce(0, (prev, element) => prev + element);
|
||||
* iterable.reduce((prev, element) => prev + element);
|
||||
*
|
||||
* *UPCOMING API-CHANGE*: this method will soon be changed to not take
|
||||
* an initial value: `iterable.reduce(min)`. Use [fold] instead.
|
||||
*/
|
||||
@deprecated
|
||||
dynamic reduce(var initialValue,
|
||||
dynamic combine(var previousValue, E element)) {
|
||||
return fold(initialValue, combine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce a collection to a single value by iteratively combining each element
|
||||
* of the collection with an existing value using the provided function.
|
||||
* Use [initialValue] as the initial value, and the function [combine] to
|
||||
* create a new value from the previous one and an element.
|
||||
*
|
||||
* Example of calculating the sum of an iterable:
|
||||
*
|
||||
* iterable.fold(0, (prev, element) => prev + element);
|
||||
*/
|
||||
dynamic fold(var initialValue,
|
||||
dynamic combine(var previousValue, E element)) {
|
||||
var value = initialValue;
|
||||
for (E element in this) value = combine(value, element);
|
||||
return value;
|
||||
|
|
|
@ -7329,6 +7329,10 @@ class DomMimeTypeArray implements JavaScriptIndexingBehavior, List<DomMimeType>
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, DomMimeType)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(DomMimeType element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(DomMimeType element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -7593,6 +7597,10 @@ class DomPluginArray implements JavaScriptIndexingBehavior, List<DomPlugin> nati
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, DomPlugin)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(DomPlugin element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(DomPlugin element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -7964,6 +7972,10 @@ class DomStringList implements JavaScriptIndexingBehavior, List<String> native "
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, String)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
// contains() defined by IDL.
|
||||
|
||||
void forEach(void f(String element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -8341,6 +8353,11 @@ class _ChildrenElementList implements List {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, Element element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
|
||||
throw new UnimplementedError();
|
||||
}
|
||||
|
@ -8587,6 +8604,11 @@ class _FrozenElementList implements List {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, Element element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
|
||||
throw new UnsupportedError('');
|
||||
}
|
||||
|
@ -10917,6 +10939,10 @@ class FileList implements JavaScriptIndexingBehavior, List<File> native "*FileLi
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, File)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(File element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(File element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -11486,6 +11512,10 @@ class Float32Array extends ArrayBufferView implements JavaScriptIndexingBehavior
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, num)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(num element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(num element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -11714,6 +11744,10 @@ class Float64Array extends ArrayBufferView implements JavaScriptIndexingBehavior
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, num)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(num element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(num element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -12362,6 +12396,10 @@ class HtmlAllCollection implements JavaScriptIndexingBehavior, List<Node> native
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -12579,6 +12617,10 @@ class HtmlCollection implements JavaScriptIndexingBehavior, List<Node> native "*
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -14619,6 +14661,10 @@ class Int16Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -14847,6 +14893,10 @@ class Int32Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -15075,6 +15125,10 @@ class Int8Array extends ArrayBufferView implements JavaScriptIndexingBehavior, L
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -17653,6 +17707,11 @@ class _ChildNodeListLazy implements List {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, Node element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
String join([String separator]) {
|
||||
return IterableMixinWorkaround.joinList(this, separator);
|
||||
}
|
||||
|
@ -18151,6 +18210,10 @@ class NodeList implements JavaScriptIndexingBehavior, List<Node> native "*NodeLi
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -20471,6 +20534,10 @@ class SourceBufferList extends EventTarget implements JavaScriptIndexingBehavior
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, SourceBuffer)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(SourceBuffer element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(SourceBuffer element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -20761,6 +20828,10 @@ class SpeechGrammarList implements JavaScriptIndexingBehavior, List<SpeechGramma
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechGrammar)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(SpeechGrammar element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(SpeechGrammar element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -22201,6 +22272,10 @@ class TextTrackCueList implements List<TextTrackCue>, JavaScriptIndexingBehavior
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, TextTrackCue)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(TextTrackCue element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(TextTrackCue element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -22416,6 +22491,10 @@ class TextTrackList extends EventTarget implements JavaScriptIndexingBehavior, L
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, TextTrack)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(TextTrack element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(TextTrack element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -22857,6 +22936,10 @@ class TouchList implements JavaScriptIndexingBehavior, List<Touch> native "*Touc
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Touch)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Touch element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Touch element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -23335,6 +23418,10 @@ class Uint16Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -23563,6 +23650,10 @@ class Uint32Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -23791,6 +23882,10 @@ class Uint8Array extends ArrayBufferView implements JavaScriptIndexingBehavior,
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -24016,6 +24111,10 @@ class Uint8ClampedArray extends Uint8Array implements JavaScriptIndexingBehavior
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -26556,6 +26655,10 @@ class _ClientRectList implements JavaScriptIndexingBehavior, List<Rect> native "
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Rect)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Rect element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Rect element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -26763,6 +26866,10 @@ class _CssRuleList implements JavaScriptIndexingBehavior, List<CssRule> native "
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, CssRule)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(CssRule element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(CssRule element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -26970,6 +27077,10 @@ class _CssValueList extends CssValue implements List<CssValue>, JavaScriptIndexi
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, CssValue)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(CssValue element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(CssValue element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -27177,6 +27288,10 @@ class _EntryArray implements JavaScriptIndexingBehavior, List<Entry> native "*En
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Entry)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Entry element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Entry element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -27384,6 +27499,10 @@ class _EntryArraySync implements JavaScriptIndexingBehavior, List<EntrySync> nat
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, EntrySync)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(EntrySync element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(EntrySync element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -27591,6 +27710,10 @@ class _GamepadList implements JavaScriptIndexingBehavior, List<Gamepad> native "
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Gamepad)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Gamepad element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Gamepad element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -27861,6 +27984,10 @@ class _NamedNodeMap implements JavaScriptIndexingBehavior, List<Node> native "*N
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -28092,6 +28219,10 @@ class _SpeechInputResultList implements JavaScriptIndexingBehavior, List<SpeechI
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechInputResult)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(SpeechInputResult element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(SpeechInputResult element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -28299,6 +28430,10 @@ class _SpeechRecognitionResultList implements JavaScriptIndexingBehavior, List<S
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechRecognitionResult)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(SpeechRecognitionResult element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(SpeechRecognitionResult element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -28506,6 +28641,10 @@ class _StyleSheetList implements JavaScriptIndexingBehavior, List<StyleSheet> na
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, StyleSheet)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(StyleSheet element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(StyleSheet element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -29148,6 +29287,11 @@ abstract class CssClassSet implements Set<String> {
|
|||
dynamic combine(dynamic previousValue, String element)) {
|
||||
return readClasses().reduce(initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, String element)) {
|
||||
return readClasses().fold(initialValue, combine);
|
||||
}
|
||||
// interface Collection - END
|
||||
|
||||
// interface Set - BEGIN
|
||||
|
@ -31571,6 +31715,9 @@ class _WrappedList<E> implements List<E> {
|
|||
dynamic reduce(initialValue, combine(previousValue, E element)) =>
|
||||
_list.reduce(initialValue, combine);
|
||||
|
||||
dynamic fold(initialValue, combine(previousValue, E element)) =>
|
||||
_list.fold(initialValue, combine);
|
||||
|
||||
bool every(bool f(E element)) => _list.every(f);
|
||||
|
||||
String join([String separator]) => _list.join(separator);
|
||||
|
|
|
@ -7996,6 +7996,10 @@ class DomMimeTypeArray extends NativeFieldWrapperClass1 implements List<DomMimeT
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, DomMimeType)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(DomMimeType element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(DomMimeType element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -8274,6 +8278,10 @@ class DomPluginArray extends NativeFieldWrapperClass1 implements List<DomPlugin>
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, DomPlugin)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(DomPlugin element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(DomPlugin element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -8670,6 +8678,10 @@ class DomStringList extends NativeFieldWrapperClass1 implements List<String> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, String)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
// contains() defined by IDL.
|
||||
|
||||
void forEach(void f(String element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -9068,6 +9080,11 @@ class _ChildrenElementList implements List {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, Element element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
|
||||
throw new UnimplementedError();
|
||||
}
|
||||
|
@ -9314,6 +9331,11 @@ class _FrozenElementList implements List {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, Element element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
|
||||
throw new UnsupportedError('');
|
||||
}
|
||||
|
@ -11581,6 +11603,10 @@ class FileList extends NativeFieldWrapperClass1 implements List<File> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, File)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(File element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(File element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -12202,6 +12228,10 @@ class Float32Array extends ArrayBufferView implements List<double> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, num)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(num element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(num element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -12447,6 +12477,10 @@ class Float64Array extends ArrayBufferView implements List<double> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, num)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(num element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(num element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -13141,6 +13175,10 @@ class HtmlAllCollection extends NativeFieldWrapperClass1 implements List<Node> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -13360,6 +13398,10 @@ class HtmlCollection extends NativeFieldWrapperClass1 implements List<Node> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -15726,6 +15768,10 @@ class Int16Array extends ArrayBufferView implements List<int> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -15971,6 +16017,10 @@ class Int32Array extends ArrayBufferView implements List<int> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -16216,6 +16266,10 @@ class Int8Array extends ArrayBufferView implements List<int> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -19088,6 +19142,11 @@ class _ChildNodeListLazy implements List {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, Node element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
String join([String separator]) {
|
||||
return IterableMixinWorkaround.joinList(this, separator);
|
||||
}
|
||||
|
@ -19583,6 +19642,10 @@ class NodeList extends NativeFieldWrapperClass1 implements List<Node> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -22186,6 +22249,10 @@ class SourceBufferList extends EventTarget implements List<SourceBuffer> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, SourceBuffer)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(SourceBuffer element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(SourceBuffer element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -22514,6 +22581,10 @@ class SpeechGrammarList extends NativeFieldWrapperClass1 implements List<SpeechG
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechGrammar)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(SpeechGrammar element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(SpeechGrammar element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -24240,6 +24311,10 @@ class TextTrackCueList extends NativeFieldWrapperClass1 implements List<TextTrac
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, TextTrackCue)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(TextTrackCue element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(TextTrackCue element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -24459,6 +24534,10 @@ class TextTrackList extends EventTarget implements List<TextTrack> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, TextTrack)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(TextTrack element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(TextTrack element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -24895,6 +24974,10 @@ class TouchList extends NativeFieldWrapperClass1 implements List<Touch> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Touch)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Touch element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Touch element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -25414,6 +25497,10 @@ class Uint16Array extends ArrayBufferView implements List<int> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -25659,6 +25746,10 @@ class Uint32Array extends ArrayBufferView implements List<int> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -25904,6 +25995,10 @@ class Uint8Array extends ArrayBufferView implements List<int> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -26147,6 +26242,10 @@ class Uint8ClampedArray extends Uint8Array implements List<int> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, int)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(int element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(int element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -28482,6 +28581,10 @@ class _ClientRectList extends NativeFieldWrapperClass1 implements List<Rect> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Rect)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Rect element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Rect element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -28693,6 +28796,10 @@ class _CssRuleList extends NativeFieldWrapperClass1 implements List<CssRule> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, CssRule)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(CssRule element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(CssRule element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -28904,6 +29011,10 @@ class _CssValueList extends CssValue implements List<CssValue> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, CssValue)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(CssValue element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(CssValue element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -29258,6 +29369,10 @@ class _EntryArray extends NativeFieldWrapperClass1 implements List<Entry> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Entry)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Entry element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Entry element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -29469,6 +29584,10 @@ class _EntryArraySync extends NativeFieldWrapperClass1 implements List<EntrySync
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, EntrySync)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(EntrySync element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(EntrySync element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -29680,6 +29799,10 @@ class _GamepadList extends NativeFieldWrapperClass1 implements List<Gamepad> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Gamepad)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Gamepad element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Gamepad element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -29982,6 +30105,10 @@ class _NamedNodeMap extends NativeFieldWrapperClass1 implements List<Node> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Node)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Node element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Node element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -30217,6 +30344,10 @@ class _SpeechInputResultList extends NativeFieldWrapperClass1 implements List<Sp
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechInputResult)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(SpeechInputResult element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(SpeechInputResult element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -30428,6 +30559,10 @@ class _SpeechRecognitionResultList extends NativeFieldWrapperClass1 implements L
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, SpeechRecognitionResult)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(SpeechRecognitionResult element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(SpeechRecognitionResult element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -30639,6 +30774,10 @@ class _StyleSheetList extends NativeFieldWrapperClass1 implements List<StyleShee
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, StyleSheet)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(StyleSheet element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(StyleSheet element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -31283,6 +31422,11 @@ abstract class CssClassSet implements Set<String> {
|
|||
dynamic combine(dynamic previousValue, String element)) {
|
||||
return readClasses().reduce(initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, String element)) {
|
||||
return readClasses().fold(initialValue, combine);
|
||||
}
|
||||
// interface Collection - END
|
||||
|
||||
// interface Set - BEGIN
|
||||
|
@ -33124,6 +33268,9 @@ class _WrappedList<E> implements List<E> {
|
|||
dynamic reduce(initialValue, combine(previousValue, E element)) =>
|
||||
_list.reduce(initialValue, combine);
|
||||
|
||||
dynamic fold(initialValue, combine(previousValue, E element)) =>
|
||||
_list.fold(initialValue, combine);
|
||||
|
||||
bool every(bool f(E element)) => _list.every(f);
|
||||
|
||||
String join([String separator]) => _list.join(separator);
|
||||
|
|
|
@ -145,6 +145,12 @@ class FilteredElementList implements List {
|
|||
dynamic combine(dynamic previousValue, Element element)) {
|
||||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, Element element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool every(bool f(Element element)) => _filtered.every(f);
|
||||
bool any(bool f(Element element)) => _filtered.any(f);
|
||||
List<Element> toList({ bool growable: true }) =>
|
||||
|
|
|
@ -260,7 +260,7 @@ class _HttpClientResponse
|
|||
// TODO(sgjesse): Support digest.
|
||||
if (cr.scheme == _AuthenticationScheme.BASIC) {
|
||||
// Drain body and retry.
|
||||
return reduce(null, (x, y) {}).then((_) {
|
||||
return fold(null, (x, y) {}).then((_) {
|
||||
return _httpClient._openUrlFromRequest(_httpRequest.method,
|
||||
_httpRequest.uri,
|
||||
_httpRequest)
|
||||
|
@ -460,7 +460,7 @@ abstract class _HttpOutboundMessage<T> implements IOSink {
|
|||
int contentLength = headers.contentLength;
|
||||
if (_ignoreBody) {
|
||||
ioSink.close();
|
||||
return stream.reduce(null, (x, y) {}).then((_) => this);
|
||||
return stream.fold(null, (x, y) {}).then((_) => this);
|
||||
}
|
||||
stream = stream.transform(new _BufferTransformer());
|
||||
if (headers.chunkedTransferEncoding) {
|
||||
|
@ -735,11 +735,11 @@ class _HttpClientRequest extends _HttpOutboundMessage<HttpClientRequest>
|
|||
if (followRedirects && response.isRedirect) {
|
||||
if (response.redirects.length < maxRedirects) {
|
||||
// Redirect and drain response.
|
||||
future = response.reduce(null, (x, y) {})
|
||||
future = response.fold(null, (x, y) {})
|
||||
.then((_) => response.redirect());
|
||||
} else {
|
||||
// End with exception, too many redirects.
|
||||
future = response.reduce(null, (x, y) {})
|
||||
future = response.fold(null, (x, y) {})
|
||||
.then((_) => new Future.immediateError(
|
||||
new RedirectLimitExceededException(response.redirects)));
|
||||
}
|
||||
|
@ -1097,7 +1097,7 @@ class _HttpClient implements HttpClient {
|
|||
_closing = true;
|
||||
// Create flattened copy of _idleConnections, as 'destory' will manipulate
|
||||
// it.
|
||||
var idle = _idleConnections.values.reduce(
|
||||
var idle = _idleConnections.values.fold(
|
||||
[],
|
||||
(l, e) {
|
||||
l.addAll(e);
|
||||
|
@ -1249,7 +1249,7 @@ class _HttpClient implements HttpClient {
|
|||
_Credentials _findCredentials(Uri url, [_AuthenticationScheme scheme]) {
|
||||
// Look for credentials.
|
||||
_Credentials cr =
|
||||
_credentials.reduce(null, (_Credentials prev, _Credentials value) {
|
||||
_credentials.fold(null, (_Credentials prev, _Credentials value) {
|
||||
if (value.applies(url, scheme)) {
|
||||
if (prev == null) return value;
|
||||
return value.uri.path.length > prev.uri.path.length ? value : prev;
|
||||
|
|
|
@ -3073,6 +3073,10 @@ class LengthList implements JavaScriptIndexingBehavior, List<Length> native "*SV
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Length)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Length element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Length element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -3707,6 +3711,10 @@ class NumberList implements JavaScriptIndexingBehavior, List<Number> native "*SV
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Number)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Number element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Number element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -4617,6 +4625,10 @@ class PathSegList implements JavaScriptIndexingBehavior, List<PathSeg> native "*
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, PathSeg)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(PathSeg element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(PathSeg element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -5512,6 +5524,10 @@ class StringList implements JavaScriptIndexingBehavior, List<String> native "*SV
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, String)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(String element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(String element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -6684,6 +6700,10 @@ class TransformList implements List<Transform>, JavaScriptIndexingBehavior nativ
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Transform)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Transform element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Transform element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -7211,6 +7231,10 @@ class _ElementInstanceList implements JavaScriptIndexingBehavior, List<ElementIn
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, ElementInstance)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(ElementInstance element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(ElementInstance element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
|
|
@ -3336,6 +3336,10 @@ class LengthList extends NativeFieldWrapperClass1 implements List<Length> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Length)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Length element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Length element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -4047,6 +4051,10 @@ class NumberList extends NativeFieldWrapperClass1 implements List<Number> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Number)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Number element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Number element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -5234,6 +5242,10 @@ class PathSegList extends NativeFieldWrapperClass1 implements List<PathSeg> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, PathSeg)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(PathSeg element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(PathSeg element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -6226,6 +6238,10 @@ class StringList extends NativeFieldWrapperClass1 implements List<String> {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, String)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(String element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(String element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -7487,6 +7503,10 @@ class TransformList extends NativeFieldWrapperClass1 implements List<Transform>
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Transform)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Transform element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Transform element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
@ -8068,6 +8088,10 @@ class _ElementInstanceList extends NativeFieldWrapperClass1 implements List<Elem
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, ElementInstance)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(ElementInstance element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(ElementInstance element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
|
|
@ -267,6 +267,10 @@ class SqlResultSetRowList implements JavaScriptIndexingBehavior, List<Map> nativ
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Map)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Map element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Map element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
|
|
@ -289,6 +289,10 @@ class SqlResultSetRowList extends NativeFieldWrapperClass1 implements List<Map>
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, Map)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
bool contains(Map element) => IterableMixinWorkaround.contains(this, element);
|
||||
|
||||
void forEach(void f(Map element)) => IterableMixinWorkaround.forEach(this, f);
|
||||
|
|
|
@ -8,13 +8,12 @@ import 'dart:collection' show Queue;
|
|||
|
||||
class CollectionTest {
|
||||
CollectionTest(Collection collection) {
|
||||
testReduce(collection);
|
||||
testFold(collection);
|
||||
}
|
||||
|
||||
void testReduce(Collection collection) {
|
||||
Expect.equals(28, collection.reduce(0, (prev, element) => prev + element));
|
||||
Expect.equals(
|
||||
3024, collection.reduce(1, (prev, element) => prev * element));
|
||||
void testFold(Collection collection) {
|
||||
Expect.equals(28, collection.fold(0, (prev, element) => prev + element));
|
||||
Expect.equals(3024, collection.fold(1, (prev, element) => prev * element));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ void testOperations() {
|
|||
testOp((i) => i.max(), "max");
|
||||
testOp((i) => i.min(), "min");
|
||||
testOp((i) => i.reduce(0, (a, b) => a + b), "reduce-sum");
|
||||
testOp((i) => i.fold(0, (a, b) => a + b), "fold-sum");
|
||||
testOp((i) => i.join("-"), "join-");
|
||||
testOp((i) => i.join(""), "join");
|
||||
testOp((i) => i.join(), "join-null");
|
||||
|
|
|
@ -107,6 +107,7 @@ void testOperations() {
|
|||
testOp((i) => i.max(), "max");
|
||||
testOp((i) => i.min(), "min");
|
||||
testOp((i) => i.reduce(0, (a, b) => a + b), "reduce-sum");
|
||||
testOp((i) => i.fold(0, (a, b) => a + b), "fold-sum");
|
||||
testOp((i) => i.join("-"), "join-");
|
||||
testOp((i) => i.join(""), "join");
|
||||
testOp((i) => i.join(), "join-null");
|
||||
|
|
|
@ -194,6 +194,10 @@ main() {
|
|||
stream.reduce(null, (a, b) => null).then((_) {});
|
||||
});
|
||||
|
||||
test('fold', () {
|
||||
stream.fold(null, (a, b) => null).then((_) {});
|
||||
});
|
||||
|
||||
test('contains', () {
|
||||
stream.contains((_) => true).then((_) {});
|
||||
});
|
||||
|
|
|
@ -11,11 +11,11 @@ import '../../../pkg/unittest/lib/unittest.dart';
|
|||
import 'event_helper.dart';
|
||||
|
||||
testController() {
|
||||
// Test reduce
|
||||
test("StreamController.reduce", () {
|
||||
// Test fold
|
||||
test("StreamController.fold", () {
|
||||
StreamController c = new StreamController.broadcast();
|
||||
Stream stream = c.stream;
|
||||
stream.reduce(0, (a,b) => a + b)
|
||||
stream.fold(0, (a,b) => a + b)
|
||||
.then(expectAsync1((int v) {
|
||||
Expect.equals(42, v);
|
||||
}));
|
||||
|
@ -24,10 +24,10 @@ testController() {
|
|||
c.close();
|
||||
});
|
||||
|
||||
test("StreamController.reduce throws", () {
|
||||
test("StreamController.fold throws", () {
|
||||
StreamController c = new StreamController.broadcast();
|
||||
Stream stream = c.stream;
|
||||
stream.reduce(0, (a,b) { throw "Fnyf!"; })
|
||||
stream.fold(0, (a,b) { throw "Fnyf!"; })
|
||||
.catchError(expectAsync1((e) { Expect.equals("Fnyf!", e.error); }));
|
||||
c.add(42);
|
||||
});
|
||||
|
@ -50,20 +50,20 @@ testController() {
|
|||
}
|
||||
|
||||
testSingleController() {
|
||||
test("Single-subscription StreamController.reduce", () {
|
||||
test("Single-subscription StreamController.fold", () {
|
||||
StreamController c = new StreamController();
|
||||
Stream stream = c.stream;
|
||||
stream.reduce(0, (a,b) => a + b)
|
||||
stream.fold(0, (a,b) => a + b)
|
||||
.then(expectAsync1((int v) { Expect.equals(42, v); }));
|
||||
c.add(10);
|
||||
c.add(32);
|
||||
c.close();
|
||||
});
|
||||
|
||||
test("Single-subscription StreamController.reduce throws", () {
|
||||
test("Single-subscription StreamController.fold throws", () {
|
||||
StreamController c = new StreamController();
|
||||
Stream stream = c.stream;
|
||||
stream.reduce(0, (a,b) { throw "Fnyf!"; })
|
||||
stream.fold(0, (a,b) { throw "Fnyf!"; })
|
||||
.catchError(expectAsync1((e) { Expect.equals("Fnyf!", e.error); }));
|
||||
c.add(42);
|
||||
});
|
||||
|
@ -449,6 +449,7 @@ testRethrow() {
|
|||
testFuture("min", (s, act) => s.min((a, b) => act(b)));
|
||||
testFuture("max", (s, act) => s.max((a, b) => act(b)));
|
||||
testFuture("reduce", (s, act) => s.reduce(0, (a,b) => act(b)));
|
||||
testFuture("fold", (s, act) => s.fold(0, (a,b) => act(b)));
|
||||
}
|
||||
|
||||
main() {
|
||||
|
|
|
@ -98,7 +98,7 @@ void testBasicNoCredentials() {
|
|||
.then((HttpClientRequest request) => request.close())
|
||||
.then((HttpClientResponse response) {
|
||||
Expect.equals(HttpStatus.UNAUTHORIZED, response.statusCode);
|
||||
return response.reduce(null, (x, y) {});
|
||||
return response.fold(null, (x, y) {});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ void testBasicCredentials() {
|
|||
.then((HttpClientRequest request) => request.close())
|
||||
.then((HttpClientResponse response) {
|
||||
Expect.equals(HttpStatus.OK, response.statusCode);
|
||||
return response.reduce(null, (x, y) {});
|
||||
return response.fold(null, (x, y) {});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -181,7 +181,7 @@ void testBasicAuthenticateCallback() {
|
|||
.then((HttpClientRequest request) => request.close())
|
||||
.then((HttpClientResponse response) {
|
||||
Expect.equals(HttpStatus.OK, response.statusCode);
|
||||
return response.reduce(null, (x, y) {});
|
||||
return response.fold(null, (x, y) {});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ void testServerCompress() {
|
|||
response.headers.value(HttpHeaders.CONTENT_ENCODING));
|
||||
response
|
||||
.transform(new ZLibInflater())
|
||||
.reduce([], (list, b) {
|
||||
.fold([], (list, b) {
|
||||
list.addAll(b);
|
||||
return list;
|
||||
}).then((list) {
|
||||
|
|
|
@ -14,7 +14,7 @@ Future getData(HttpClient client, int port, bool chunked, int length) {
|
|||
return client.get("localhost", port, "/?chunked=$chunked&length=$length")
|
||||
.then((request) => request.close())
|
||||
.then((response) {
|
||||
return response.reduce(0, (bytes, data) => bytes + data.length)
|
||||
return response.fold(0, (bytes, data) => bytes + data.length)
|
||||
.then((bytes) {
|
||||
Expect.equals(length, bytes);
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@ class Server {
|
|||
var response = request.response;
|
||||
requestCount++;
|
||||
// Check whether a proxy or direct connection is expected.
|
||||
bool direct = directRequestPaths.reduce(
|
||||
bool direct = directRequestPaths.fold(
|
||||
false,
|
||||
(prev, path) => prev ? prev : path == request.uri.path);
|
||||
if (!direct && proxyHops > 0) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'dart:io';
|
|||
const SESSION_ID = "DARTSESSID";
|
||||
|
||||
String getSessionId(List<Cookie> cookies) {
|
||||
var id = cookies.reduce(null, (last, cookie) {
|
||||
var id = cookies.fold(null, (last, cookie) {
|
||||
if (last != null) return last;
|
||||
if (cookie.name.toUpperCase() == SESSION_ID) {
|
||||
Expect.isTrue(cookie.httpOnly);
|
||||
|
@ -30,7 +30,7 @@ Future<String> connectGetSession(
|
|||
return request.close();
|
||||
})
|
||||
.then((response) {
|
||||
return response.reduce(getSessionId(response.cookies), (v, _) => v);
|
||||
return response.fold(getSessionId(response.cookies), (v, _) => v);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ Function test() {
|
|||
.then((response) {
|
||||
Expect.equals('CN=localhost', response.certificate.subject);
|
||||
Expect.equals('CN=myauthority', response.certificate.issuer);
|
||||
return response.reduce(<int>[],
|
||||
(message, data) => message..addAll(data));
|
||||
return response.fold(<int>[],
|
||||
(message, data) => message..addAll(data));
|
||||
})
|
||||
.then((message) {
|
||||
String received = new String.fromCharCodes(message);
|
||||
|
|
|
@ -44,7 +44,7 @@ Future<RawSecureServerSocket> startEchoServer() {
|
|||
}
|
||||
break;
|
||||
case RawSocketEvent.READ_CLOSED:
|
||||
dataToWrite = readChunks.reduce(<int>[], (list, x) {
|
||||
dataToWrite = readChunks.fold(<int>[], (list, x) {
|
||||
list.addAll(x);
|
||||
return list;
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ Future<SecureServerSocket> startEchoServer() {
|
|||
5,
|
||||
CERTIFICATE).then((server) {
|
||||
server.listen((SecureSocket client) {
|
||||
client.reduce(<int>[], (message, data) => message..addAll(data))
|
||||
client.fold(<int>[], (message, data) => message..addAll(data))
|
||||
.then((message) {
|
||||
client.writeBytes(message);
|
||||
client.close();
|
||||
|
@ -34,7 +34,7 @@ Future testClient(server) {
|
|||
return SecureSocket.connect(HOST_NAME, server.port).then((socket) {
|
||||
socket.write("Hello server.");
|
||||
socket.close();
|
||||
return socket.reduce(<int>[], (message, data) => message..addAll(data))
|
||||
return socket.fold(<int>[], (message, data) => message..addAll(data))
|
||||
.then((message) {
|
||||
Expect.listEquals("Hello server.".codeUnits, message);
|
||||
return server;
|
||||
|
|
|
@ -20,7 +20,7 @@ Future<SecureServerSocket> startServer() {
|
|||
5,
|
||||
CERTIFICATE).then((server) {
|
||||
server.listen((SecureSocket client) {
|
||||
client.reduce(<int>[], (message, data) => message..addAll(data))
|
||||
client.fold(<int>[], (message, data) => message..addAll(data))
|
||||
.then((message) {
|
||||
String received = new String.fromCharCodes(message);
|
||||
Expect.isTrue(received.contains("Hello from client "));
|
||||
|
@ -37,7 +37,7 @@ Future testClient(server, name) {
|
|||
return SecureSocket.connect(HOST_NAME, server.port).then((socket) {
|
||||
socket.writeBytes("Hello from client $name".codeUnits);
|
||||
socket.close();
|
||||
return socket.reduce(<int>[], (message, data) => message..addAll(data))
|
||||
return socket.fold(<int>[], (message, data) => message..addAll(data))
|
||||
.then((message) {
|
||||
Expect.listEquals("Welcome, client $name".codeUnits, message);
|
||||
return server;
|
||||
|
|
|
@ -29,7 +29,7 @@ Future<SecureServerSocket> startServer() {
|
|||
5,
|
||||
CERTIFICATE).then((server) {
|
||||
server.listen((SecureSocket client) {
|
||||
client.reduce(<int>[], (message, data) => message..addAll(data))
|
||||
client.fold(<int>[], (message, data) => message..addAll(data))
|
||||
.then((message) {
|
||||
String received = new String.fromCharCodes(message);
|
||||
Expect.isTrue(received.contains("Hello from client "));
|
||||
|
@ -46,7 +46,7 @@ Future testClient(server, name) {
|
|||
return SecureSocket.connect(HOST_NAME, server.port).then((socket) {
|
||||
socket.write("Hello from client $name");
|
||||
socket.close();
|
||||
return socket.reduce(<int>[], (message, data) => message..addAll(data))
|
||||
return socket.fold(<int>[], (message, data) => message..addAll(data))
|
||||
.then((message) {
|
||||
Expect.listEquals("Welcome, client $name".codeUnits, message);
|
||||
return server;
|
||||
|
|
|
@ -51,7 +51,7 @@ Future testCertificateCallback({String host, bool acceptCertificate}) {
|
|||
Expect.isTrue(acceptCertificate);
|
||||
socket.write("GET / HTTP/1.0\r\nHost: $host\r\n\r\n");
|
||||
socket.close();
|
||||
return socket.reduce(<int>[], (message, data) => message..addAll(data))
|
||||
return socket.fold(<int>[], (message, data) => message..addAll(data))
|
||||
.then((message) {
|
||||
String received = new String.fromCharCodes(message);
|
||||
Expect.isTrue(received.contains('</body></html>'));
|
||||
|
|
|
@ -17,7 +17,7 @@ void test() {
|
|||
|
||||
var decoder = new StringDecoder(Encoding.UTF_8, '?'.codeUnitAt(0));
|
||||
var stream = controller.stream.transform(decoder);
|
||||
stream.reduce(
|
||||
stream.fold(
|
||||
new StringBuffer(),
|
||||
(b, e) {
|
||||
b.write(e);
|
||||
|
|
|
@ -12,7 +12,7 @@ void testZLibDeflate() {
|
|||
var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
var controller = new StreamController();
|
||||
controller.stream.transform(new ZLibDeflater(gzip: false, level: level))
|
||||
.reduce([], (buffer, data) {
|
||||
.fold([], (buffer, data) {
|
||||
buffer.addAll(data);
|
||||
return buffer;
|
||||
})
|
||||
|
@ -52,7 +52,7 @@ void testZLibDeflateEmpty() {
|
|||
var port = new ReceivePort();
|
||||
var controller = new StreamController();
|
||||
controller.stream.transform(new ZLibDeflater(gzip: false, level: 6))
|
||||
.reduce([], (buffer, data) {
|
||||
.fold([], (buffer, data) {
|
||||
buffer.addAll(data);
|
||||
return buffer;
|
||||
})
|
||||
|
@ -70,7 +70,7 @@ void testZLibDeflateGZip() {
|
|||
var data = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
var controller = new StreamController();
|
||||
controller.stream.transform(new ZLibDeflater())
|
||||
.reduce([], (buffer, data) {
|
||||
.fold([], (buffer, data) {
|
||||
buffer.addAll(data);
|
||||
return buffer;
|
||||
})
|
||||
|
@ -116,7 +116,7 @@ void testZLibInflate() {
|
|||
controller.stream
|
||||
.transform(new ZLibDeflater(gzip: gzip, level: level))
|
||||
.transform(new ZLibInflater())
|
||||
.reduce([], (buffer, data) {
|
||||
.fold([], (buffer, data) {
|
||||
buffer.addAll(data);
|
||||
return buffer;
|
||||
})
|
||||
|
|
|
@ -62,6 +62,11 @@ abstract class CssClassSet implements Set<String> {
|
|||
dynamic combine(dynamic previousValue, String element)) {
|
||||
return readClasses().reduce(initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, String element)) {
|
||||
return readClasses().fold(initialValue, combine);
|
||||
}
|
||||
// interface Collection - END
|
||||
|
||||
// interface Set - BEGIN
|
||||
|
|
|
@ -30,6 +30,9 @@ class _WrappedList<E> implements List<E> {
|
|||
dynamic reduce(initialValue, combine(previousValue, E element)) =>
|
||||
_list.reduce(initialValue, combine);
|
||||
|
||||
dynamic fold(initialValue, combine(previousValue, E element)) =>
|
||||
_list.fold(initialValue, combine);
|
||||
|
||||
bool every(bool f(E element)) => _list.every(f);
|
||||
|
||||
String join([String separator]) => _list.join(separator);
|
||||
|
|
|
@ -162,6 +162,11 @@ class _ChildrenElementList implements List {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, Element element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
|
||||
throw new UnimplementedError();
|
||||
}
|
||||
|
@ -408,6 +413,11 @@ class _FrozenElementList implements List {
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, Element element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
void setRange(int start, int rangeLength, List from, [int startFrom = 0]) {
|
||||
throw new UnsupportedError('');
|
||||
}
|
||||
|
|
|
@ -150,6 +150,11 @@ $endif
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue,
|
||||
dynamic combine(dynamic previousValue, Node element)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
String join([String separator]) {
|
||||
return IterableMixinWorkaround.joinList(this, separator);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,10 @@ $endif
|
|||
return IterableMixinWorkaround.reduce(this, initialValue, combine);
|
||||
}
|
||||
|
||||
dynamic fold(dynamic initialValue, dynamic combine(dynamic, $E)) {
|
||||
return IterableMixinWorkaround.fold(this, initialValue, combine);
|
||||
}
|
||||
|
||||
$if DEFINE_CONTAINS
|
||||
bool contains($E element) => IterableMixinWorkaround.contains(this, element);
|
||||
$else
|
||||
|
|
|
@ -328,7 +328,7 @@ Future<bool> confirm(String message) {
|
|||
/// Reads and discards all output from [stream]. Returns a [Future] that
|
||||
/// completes when the stream is closed.
|
||||
Future drainStream(Stream stream) {
|
||||
return stream.reduce(null, (x, y) {});
|
||||
return stream.fold(null, (x, y) {});
|
||||
}
|
||||
|
||||
/// Returns a [EventSink] that pipes all data to [consumer] and a [Future] that
|
||||
|
|
Loading…
Reference in a new issue