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

Side by Side Diff: pkg/http/lib/src/utils.dart

Issue 12090093: Reapply "Rename mappedBy to map." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed bug in previous commit. Created 7 years, 10 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 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library utils; 5 library utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:crypto'; 8 import 'dart:crypto';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:scalarlist'; 10 import 'dart:scalarlist';
(...skipping 20 matching lines...) Expand all
31 } 31 }
32 32
33 /// Converts a [Map] from parameter names to values to a URL query string. 33 /// Converts a [Map] from parameter names to values to a URL query string.
34 /// 34 ///
35 /// mapToQuery({"foo": "bar", "baz": "bang"}); 35 /// mapToQuery({"foo": "bar", "baz": "bang"});
36 /// //=> "foo=bar&baz=bang" 36 /// //=> "foo=bar&baz=bang"
37 String mapToQuery(Map<String, String> map) { 37 String mapToQuery(Map<String, String> map) {
38 var pairs = <List<String>>[]; 38 var pairs = <List<String>>[];
39 map.forEach((key, value) => 39 map.forEach((key, value) =>
40 pairs.add([encodeUriComponent(key), encodeUriComponent(value)])); 40 pairs.add([encodeUriComponent(key), encodeUriComponent(value)]));
41 return Strings.join(pairs.mappedBy((pair) => "${pair[0]}=${pair[1]}"), "&"); 41 return Strings.join(pairs.map((pair) => "${pair[0]}=${pair[1]}"), "&");
42 } 42 }
43 43
44 /// Adds all key/value pairs from [source] to [destination], overwriting any 44 /// Adds all key/value pairs from [source] to [destination], overwriting any
45 /// pre-existing values. 45 /// pre-existing values.
46 /// 46 ///
47 /// var a = {"foo": "bar", "baz": "bang"}; 47 /// var a = {"foo": "bar", "baz": "bang"};
48 /// mapAddAll(a, {"baz": "zap", "qux": "quux"}); 48 /// mapAddAll(a, {"baz": "zap", "qux": "quux"});
49 /// a; //=> {"foo": "bar", "baz": "zap", "qux": "quux"} 49 /// a; //=> {"foo": "bar", "baz": "zap", "qux": "quux"}
50 void mapAddAll(Map destination, Map source) => 50 void mapAddAll(Map destination, Map source) =>
51 source.forEach((key, value) => destination[key] = value); 51 source.forEach((key, value) => destination[key] = value);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 /// The return values of all [Future]s are discarded. Any errors will cause the 302 /// The return values of all [Future]s are discarded. Any errors will cause the
303 /// iteration to stop and will be piped through the return value. 303 /// iteration to stop and will be piped through the return value.
304 Future forEachFuture(Iterable input, Future fn(element)) { 304 Future forEachFuture(Iterable input, Future fn(element)) {
305 var iterator = input.iterator; 305 var iterator = input.iterator;
306 Future nextElement(_) { 306 Future nextElement(_) {
307 if (!iterator.moveNext()) return new Future.immediate(null); 307 if (!iterator.moveNext()) return new Future.immediate(null);
308 return fn(iterator.current).then(nextElement); 308 return fn(iterator.current).then(nextElement);
309 } 309 }
310 return nextElement(null); 310 return nextElement(null);
311 } 311 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698