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

Side by Side Diff: lib/src/asset/dart/serialize/get_input_transform.dart

Issue 2184303002: Make pub strong-mode clean. (Closed) Base URL: git@github.com:dart-lang/pub.git@master
Patch Set: Code review changes Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 7
8 import 'package:async/async.dart';
8 import 'package:barback/barback.dart'; 9 import 'package:barback/barback.dart';
9 10
10 import '../utils.dart';
11
12 /// A mixin for transforms that support [getInput] and the associated suite of 11 /// A mixin for transforms that support [getInput] and the associated suite of
13 /// methods. 12 /// methods.
14 abstract class GetInputTransform { 13 abstract class GetInputTransform {
15 Future<Asset> getInput(AssetId id); 14 Future<Asset> getInput(AssetId id);
16 15
17 Future<String> readInputAsString(AssetId id, {Encoding encoding}) { 16 Future<String> readInputAsString(AssetId id, {Encoding encoding}) {
18 if (encoding == null) encoding = UTF8; 17 if (encoding == null) encoding = UTF8;
19 return getInput(id).then((input) => 18 return getInput(id).then((input) =>
20 input.readAsString(encoding: encoding)); 19 input.readAsString(encoding: encoding));
21 } 20 }
22 21
23 Stream<List<int>> readInput(AssetId id) => 22 Stream<List<int>> readInput(AssetId id) =>
24 futureStream(getInput(id).then((input) => input.read())); 23 StreamCompleter.fromFuture(getInput(id).then((input) => input.read()));
25 24
26 Future<bool> hasInput(AssetId id) { 25 Future<bool> hasInput(AssetId id) {
27 return getInput(id).then((_) => true).catchError((error) { 26 return getInput(id).then((_) => true).catchError((error) {
28 if (error is AssetNotFoundException && error.id == id) return false; 27 if (error is AssetNotFoundException && error.id == id) return false;
29 throw error; 28 throw error;
30 }); 29 });
31 } 30 }
32 } 31 }
OLDNEW
« no previous file with comments | « lib/src/asset/dart/serialize/exception.dart ('k') | lib/src/asset/dart/serialize/transform.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698