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

Side by Side Diff: utils/pub/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
« no previous file with comments | « utils/pub/io.dart ('k') | utils/pub/validator.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 155 }
156 156
157 /// Convert a [Map] from parameter names to values to a URL query string. 157 /// Convert a [Map] from parameter names to values to a URL query string.
158 String mapToQuery(Map<String, String> map) { 158 String mapToQuery(Map<String, String> map) {
159 var pairs = <List<String>>[]; 159 var pairs = <List<String>>[];
160 map.forEach((key, value) { 160 map.forEach((key, value) {
161 key = encodeUriComponent(key); 161 key = encodeUriComponent(key);
162 value = (value == null || value.isEmpty) ? null : encodeUriComponent(value); 162 value = (value == null || value.isEmpty) ? null : encodeUriComponent(value);
163 pairs.add([key, value]); 163 pairs.add([key, value]);
164 }); 164 });
165 return Strings.join(pairs.mappedBy((pair) { 165 return Strings.join(pairs.map((pair) {
166 if (pair[1] == null) return pair[0]; 166 if (pair[1] == null) return pair[0];
167 return "${pair[0]}=${pair[1]}"; 167 return "${pair[0]}=${pair[1]}";
168 }), "&"); 168 }), "&");
169 } 169 }
170 170
171 /// Add all key/value pairs from [source] to [destination], overwriting any 171 /// Add all key/value pairs from [source] to [destination], overwriting any
172 /// pre-existing values. 172 /// pre-existing values.
173 void mapAddAll(Map destination, Map source) => 173 void mapAddAll(Map destination, Map source) =>
174 source.forEach((key, value) => destination[key] = value); 174 source.forEach((key, value) => destination[key] = value);
175 175
176 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes 176 /// Decodes a URL-encoded string. Unlike [decodeUriComponent], this includes
177 /// replacing `+` with ` `. 177 /// replacing `+` with ` `.
178 String urlDecode(String encoded) => 178 String urlDecode(String encoded) =>
179 decodeUriComponent(encoded.replaceAll("+", " ")); 179 decodeUriComponent(encoded.replaceAll("+", " "));
OLDNEW
« no previous file with comments | « utils/pub/io.dart ('k') | utils/pub/validator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698