Skip to content

Commit 73c375e

Browse files
committed
Minor code and documentation adjustments
1 parent 656a791 commit 73c375e

6 files changed

+16
-10
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ coverage/
1212
# Omit committing pubspec.lock for library packages; see
1313
# https://dart.dev/guides/libraries/private-files#pubspeclock.
1414
pubspec.lock
15+
16+
.pubignore

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ ifndef VERBOSE
22
.SILENT:
33
endif
44

5-
.PHONY: docs coverage
6-
5+
.PHONY: docs
76
docs:
87
dart doc --validate-links
98

9+
.PHONY: coverage
1010
coverage:
1111
# Reference: https://pub.dev/packages/coverage
1212
dart pub global run coverage:test_with_coverage \

lib/debug.dart

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import 'package:stack_trace/stack_trace.dart' as stacktrace;
1111
/// If [packageRelative] is false, returns an absolute path.
1212
///
1313
/// This does not work for Dart for the Web.
14+
///
15+
/// Note that [Platform.script] does not work for `import`ed files and
16+
/// consequently does not work with the Dart test runner.
17+
///
18+
/// [Platform.script]: https://api.dart.dev/stable/dart-io/Platform/script.html
1419
String currentDartFilePath({bool packageRelative = false}) {
1520
var caller = stacktrace.Frame.caller(1);
1621
return packageRelative ? caller.library : caller.uri.toFilePath();

lib/misc.dart

+3-6
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ extension PadLeftExtension on int {
8383
/// Returns a string representation of this [int], left-padded with zeroes if
8484
/// necessary to have the specified minimum number of characters.
8585
///
86-
/// If this [int] is negative, the negative sign is included in number of
86+
/// If this [int] is negative, the negative sign is included in the number of
8787
/// characters.
8888
///
8989
/// Examples:
@@ -122,7 +122,7 @@ extension ImpliesExtension on bool {
122122
/// Returns whether this [bool] [logically implies][1] [consequence].
123123
///
124124
/// Given two boolean expressions *p* and *q*, the results of "*p* implies
125-
/// *q*"" (denoted as *p → q*) are shown by the following truth table:
125+
/// *q*" (denoted as *p → q*) are shown by the following truth table:
126126
///
127127
/// | p | q | p → q |
128128
/// |:---:|:---:|:----------:|
@@ -143,10 +143,7 @@ extension FutureCast<T> on Future<T> {
143143
/// Casts a `Future<T>` to a `Future<R>`.
144144
///
145145
// Motivated by: <https://stackoverflow.com/q/72576065/>
146-
Future<R> cast<R>() async {
147-
var result = await this;
148-
return result as R;
149-
}
146+
Future<R> cast<R>() async => (await this) as R;
150147
}
151148

152149
/// An implementation of [Future] that allows synchronously retrieving the

lib/readable_numbers.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ library;
44
import 'dart:math' as math;
55

66
import 'math.dart';
7+
import 'misc.dart';
78

89
const _siMacroPrefixes = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
910
const _siMicroPrefixes = ['m', '\u03BC', 'n', 'p', 'f', 'a', 'z', 'y'];
@@ -158,8 +159,9 @@ String readableDuration(Duration duration, {int? precision}) {
158159

159160
var secondsString = '';
160161
if (microseconds > 0) {
162+
// Strip off trailing zeroes from the fractional portion.
161163
var fractionalSecondsString =
162-
'$microseconds'.padLeft(6, '0').replaceAll(RegExp(r'0+$'), '');
164+
microseconds.padLeft(6).replaceAll(RegExp(r'0+$'), '');
163165
secondsString = '$seconds.${fractionalSecondsString}s';
164166
} else if (seconds > 0) {
165167
secondsString = '${seconds}s';

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: dartbag
22

33
# Description must be 60-180 characters to appease pub.dev's scoring system.
44
description: A grab-bag of miscellaneous, lightweight utility libraries for Dart.
5-
version: 0.7.0+1
5+
version: 0.7.1-dev
66
repository: https://github.com/jamesderlin/dartbag
77

88
environment:

0 commit comments

Comments
 (0)