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

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

Issue 1691173002: Support tag configuration. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 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
« no previous file with comments | « lib/src/runner/configuration/load.dart ('k') | lib/test.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:convert'; 6 import 'dart:convert';
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 8
9 import 'package:async/async.dart' hide StreamQueue; 9 import 'package:async/async.dart' hide StreamQueue;
10 import 'package:crypto/crypto.dart'; 10 import 'package:crypto/crypto.dart';
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 helper(element); 195 helper(element);
196 } else { 196 } else {
197 result.add(element); 197 result.add(element);
198 } 198 }
199 } 199 }
200 } 200 }
201 helper(nested); 201 helper(nested);
202 return result; 202 return result;
203 } 203 }
204 204
205 /// Creates a new map from [map] with new keys and values.
206 ///
207 /// The return values of [key] are used as the keys and the return values of
208 /// [value] are used as the values for the new map.
209 ///
210 /// [key] defaults to returning the original key and [value] defaults to
211 /// returning the original value.
212 Map mapMap(Map map, {key(key, value), value(key, value)}) {
213 if (key == null) key = (key, _) => key;
214 if (value == null) value = (_, value) => value;
215
216 var result = {};
217 map.forEach((mapKey, mapValue) {
218 result[key(mapKey, mapValue)] = value(mapKey, mapValue);
219 });
220 return result;
221 }
222
205 /// Returns a new map with all values in both [map1] and [map2]. 223 /// Returns a new map with all values in both [map1] and [map2].
206 /// 224 ///
207 /// If there are conflicting keys, [map2]'s value wins. 225 /// If there are conflicting keys, [value] is used to merge them. If it's
208 Map mergeMaps(Map map1, Map map2) { 226 /// not passed, [map2]'s value wins.
209 var result = {}; 227 Map mergeMaps(Map map1, Map map2, {value(value1, value2)}) {
210 map1.forEach((key, value) { 228 var result = new Map.from(map1);
211 result[key] = value;
212 });
213 map2.forEach((key, value) { 229 map2.forEach((key, value) {
214 result[key] = value; 230 if (value == null || !result.containsKey(key)) {
231 result[key] = value;
232 } else {
233 result[key] = value(result[key], value);
234 }
215 }); 235 });
216 return result; 236 return result;
217 } 237 }
218 238
219 /// Like [runZoned], but [zoneValues] are set for the callbacks in 239 /// Like [runZoned], but [zoneValues] are set for the callbacks in
220 /// [zoneSpecification] and [onError]. 240 /// [zoneSpecification] and [onError].
221 runZonedWithValues(body(), {Map zoneValues, 241 runZonedWithValues(body(), {Map zoneValues,
222 ZoneSpecification zoneSpecification, Function onError}) { 242 ZoneSpecification zoneSpecification, Function onError}) {
223 return runZoned(() { 243 return runZoned(() {
224 return runZoned(body, 244 return runZoned(body,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 urlSafe: urlSafe, addLineSeparator: addLineSeparator); 437 urlSafe: urlSafe, addLineSeparator: addLineSeparator);
418 } 438 }
419 439
420 /// Returns middleware that nests all requests beneath the URL prefix [beneath]. 440 /// Returns middleware that nests all requests beneath the URL prefix [beneath].
421 shelf.Middleware nestingMiddleware(String beneath) { 441 shelf.Middleware nestingMiddleware(String beneath) {
422 return (handler) { 442 return (handler) {
423 var pathHandler = new PathHandler()..add(beneath, handler); 443 var pathHandler = new PathHandler()..add(beneath, handler);
424 return pathHandler.handler; 444 return pathHandler.handler;
425 }; 445 };
426 } 446 }
OLDNEW
« no previous file with comments | « lib/src/runner/configuration/load.dart ('k') | lib/test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698