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

Side by Side Diff: utils/pub/utils.dart

Issue 12086062: Rename mappedBy to map. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 /// Generic utility functions. Stuff that should possibly be in core. 5 /// Generic utility functions. Stuff that should possibly be in core.
6 library utils; 6 library utils;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:crypto'; 9 import 'dart:crypto';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 } 232 }
233 233
234 /// Convert a [Map] from parameter names to values to a URL query string. 234 /// Convert a [Map] from parameter names to values to a URL query string.
235 String mapToQuery(Map<String, String> map) { 235 String mapToQuery(Map<String, String> map) {
236 var pairs = <List<String>>[]; 236 var pairs = <List<String>>[];
237 map.forEach((key, value) { 237 map.forEach((key, value) {
238 key = encodeUriComponent(key); 238 key = encodeUriComponent(key);
239 value = (value == null || value.isEmpty) ? null : encodeUriComponent(value); 239 value = (value == null || value.isEmpty) ? null : encodeUriComponent(value);
240 pairs.add([key, value]); 240 pairs.add([key, value]);
241 }); 241 });
242 return Strings.join(pairs.mappedBy((pair) { 242 return Strings.join(pairs.map((pair) {
243 if (pair[1] == null) return pair[0]; 243 if (pair[1] == null) return pair[0];
244 return "${pair[0]}=${pair[1]}"; 244 return "${pair[0]}=${pair[1]}";
245 }), "&"); 245 }), "&");
246 } 246 }
247 247
248 /// Add all key/value pairs from [source] to [destination], overwriting any 248 /// Add all key/value pairs from [source] to [destination], overwriting any
249 /// pre-existing values. 249 /// pre-existing values.
250 void mapAddAll(Map destination, Map source) => 250 void mapAddAll(Map destination, Map source) =>
251 source.forEach((key, value) => destination[key] = value); 251 source.forEach((key, value) => destination[key] = value);
252 252
253 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes 253 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes
254 /// replacing `+` with ` `. 254 /// replacing `+` with ` `.
255 String urlDecode(String encoded) => 255 String urlDecode(String encoded) =>
256 decodeUriComponent(encoded.replaceAll("+", " ")); 256 decodeUriComponent(encoded.replaceAll("+", " "));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698