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

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

Issue 94093007: Add stack chain support to pkg/watcher and pkg/http. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | « pkg/http/lib/src/multipart_file.dart ('k') | pkg/http/pubspec.yaml » ('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 library utils; 5 library utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
11 11
12 import 'package:stack_trace/stack_trace.dart';
13
12 import 'byte_stream.dart'; 14 import 'byte_stream.dart';
13 15
14 /// Converts a URL query string (or `application/x-www-form-urlencoded` body) 16 /// Converts a URL query string (or `application/x-www-form-urlencoded` body)
15 /// into a [Map] from parameter names to values. 17 /// into a [Map] from parameter names to values.
16 /// 18 ///
17 /// queryToMap("foo=bar&baz=bang&qux"); 19 /// queryToMap("foo=bar&baz=bang&qux");
18 /// //=> {"foo": "bar", "baz": "bang", "qux": ""} 20 /// //=> {"foo": "bar", "baz": "bang", "qux": ""}
19 Map<String, String> queryToMap(String queryList, {Encoding encoding}) { 21 Map<String, String> queryToMap(String queryList, {Encoding encoding}) {
20 var map = {}; 22 var map = {};
21 for (var pair in queryList.split("&")) { 23 for (var pair in queryList.split("&")) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 /// The return values of all [Future]s are discarded. Any errors will cause the 208 /// The return values of all [Future]s are discarded. Any errors will cause the
207 /// iteration to stop and will be piped through the return value. 209 /// iteration to stop and will be piped through the return value.
208 Future forEachFuture(Iterable input, Future fn(element)) { 210 Future forEachFuture(Iterable input, Future fn(element)) {
209 var iterator = input.iterator; 211 var iterator = input.iterator;
210 Future nextElement(_) { 212 Future nextElement(_) {
211 if (!iterator.moveNext()) return new Future.value(); 213 if (!iterator.moveNext()) return new Future.value();
212 return fn(iterator.current).then(nextElement); 214 return fn(iterator.current).then(nextElement);
213 } 215 }
214 return nextElement(null); 216 return nextElement(null);
215 } 217 }
218
219 /// Like [Future.sync], but wraps the Future in [Chain.track] as well.
220 Future syncFuture(callback()) => Chain.track(new Future.sync(callback));
Bob Nystrom 2013/12/05 17:35:46 Maybe this should be added to stack_trace itself?
nweiz 2013/12/05 19:27:45 I don't want to make it part of the public API sin
OLDNEW
« no previous file with comments | « pkg/http/lib/src/multipart_file.dart ('k') | pkg/http/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698