Chromium Code Reviews| OLD | NEW |
|---|---|
| 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'; | |
| 9 import 'dart:io'; | 8 import 'dart:io'; |
| 10 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
| 11 import 'dart:utf'; | 10 import 'dart:utf'; |
| 12 | 11 |
| 12 import "package:crypto/crypto.dart"; | |
| 13 | |
| 13 import 'byte_stream.dart'; | 14 import 'byte_stream.dart'; |
| 14 | 15 |
| 16 | |
|
nweiz
2013/05/28 18:35:04
Extra newline.
Søren Gjesse
2013/05/29 07:38:08
Removed.
| |
| 15 /// Converts a URL query string (or `application/x-www-form-urlencoded` body) | 17 /// Converts a URL query string (or `application/x-www-form-urlencoded` body) |
| 16 /// into a [Map] from parameter names to values. | 18 /// into a [Map] from parameter names to values. |
| 17 /// | 19 /// |
| 18 /// queryToMap("foo=bar&baz=bang&qux"); | 20 /// queryToMap("foo=bar&baz=bang&qux"); |
| 19 /// //=> {"foo": "bar", "baz": "bang", "qux": ""} | 21 /// //=> {"foo": "bar", "baz": "bang", "qux": ""} |
| 20 Map<String, String> queryToMap(String queryList) { | 22 Map<String, String> queryToMap(String queryList) { |
| 21 var map = {}; | 23 var map = {}; |
| 22 for (var pair in queryList.split("&")) { | 24 for (var pair in queryList.split("&")) { |
| 23 var split = split1(pair, "="); | 25 var split = split1(pair, "="); |
| 24 if (split.isEmpty) continue; | 26 if (split.isEmpty) continue; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 /// The return values of all [Future]s are discarded. Any errors will cause the | 234 /// The return values of all [Future]s are discarded. Any errors will cause the |
| 233 /// iteration to stop and will be piped through the return value. | 235 /// iteration to stop and will be piped through the return value. |
| 234 Future forEachFuture(Iterable input, Future fn(element)) { | 236 Future forEachFuture(Iterable input, Future fn(element)) { |
| 235 var iterator = input.iterator; | 237 var iterator = input.iterator; |
| 236 Future nextElement(_) { | 238 Future nextElement(_) { |
| 237 if (!iterator.moveNext()) return new Future.value(); | 239 if (!iterator.moveNext()) return new Future.value(); |
| 238 return fn(iterator.current).then(nextElement); | 240 return fn(iterator.current).then(nextElement); |
| 239 } | 241 } |
| 240 return nextElement(null); | 242 return nextElement(null); |
| 241 } | 243 } |
| OLD | NEW |