| OLD | NEW |
| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 }); | 221 }); |
| 222 return result; | 222 return result; |
| 223 } | 223 } |
| 224 | 224 |
| 225 /// Returns a new map with all values in both [map1] and [map2]. | 225 /// Returns a new map with all values in both [map1] and [map2]. |
| 226 /// | 226 /// |
| 227 /// If there are conflicting keys, [value] is used to merge them. If it's | 227 /// If there are conflicting keys, [value] is used to merge them. If it's |
| 228 /// not passed, [map2]'s value wins. | 228 /// not passed, [map2]'s value wins. |
| 229 Map mergeMaps(Map map1, Map map2, {value(value1, value2)}) { | 229 Map mergeMaps(Map map1, Map map2, {value(value1, value2)}) { |
| 230 var result = new Map.from(map1); | 230 var result = new Map.from(map1); |
| 231 map2.forEach((key, value) { | 231 map2.forEach((key, mapValue) { |
| 232 if (value == null || !result.containsKey(key)) { | 232 if (value == null || !result.containsKey(key)) { |
| 233 result[key] = value; | 233 result[key] = mapValue; |
| 234 } else { | 234 } else { |
| 235 result[key] = value(result[key], value); | 235 result[key] = value(result[key], mapValue); |
| 236 } | 236 } |
| 237 }); | 237 }); |
| 238 return result; | 238 return result; |
| 239 } | 239 } |
| 240 | 240 |
| 241 /// Like [runZoned], but [zoneValues] are set for the callbacks in | 241 /// Like [runZoned], but [zoneValues] are set for the callbacks in |
| 242 /// [zoneSpecification] and [onError]. | 242 /// [zoneSpecification] and [onError]. |
| 243 runZonedWithValues(body(), {Map zoneValues, | 243 runZonedWithValues(body(), {Map zoneValues, |
| 244 ZoneSpecification zoneSpecification, Function onError}) { | 244 ZoneSpecification zoneSpecification, Function onError}) { |
| 245 return runZoned(() { | 245 return runZoned(() { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 urlSafe: urlSafe, addLineSeparator: addLineSeparator); | 439 urlSafe: urlSafe, addLineSeparator: addLineSeparator); |
| 440 } | 440 } |
| 441 | 441 |
| 442 /// Returns middleware that nests all requests beneath the URL prefix [beneath]. | 442 /// Returns middleware that nests all requests beneath the URL prefix [beneath]. |
| 443 shelf.Middleware nestingMiddleware(String beneath) { | 443 shelf.Middleware nestingMiddleware(String beneath) { |
| 444 return (handler) { | 444 return (handler) { |
| 445 var pathHandler = new PathHandler()..add(beneath, handler); | 445 var pathHandler = new PathHandler()..add(beneath, handler); |
| 446 return pathHandler.handler; | 446 return pathHandler.handler; |
| 447 }; | 447 }; |
| 448 } | 448 } |
| OLD | NEW |