Chromium Code Reviews| Index: pkg/barback/lib/src/utils.dart |
| diff --git a/pkg/barback/lib/src/utils.dart b/pkg/barback/lib/src/utils.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2e7906ede9a9526f6381529b8a773384736b8353 |
| --- /dev/null |
| +++ b/pkg/barback/lib/src/utils.dart |
| @@ -0,0 +1,13 @@ |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library barback.utils; |
| + |
| +/// Converts a number in the range [0-255] to a two digit hex string. |
| +/// |
| +/// For example, given `255`, returns `ff`. |
| +String byteToHex(int byte) { |
|
nweiz
2013/07/09 02:00:01
assert(byte >= 0 && byte < 256)
Bob Nystrom
2013/07/09 16:26:03
Done.
|
| + const DIGITS = "0123456789abcdef"; |
| + return DIGITS[(byte ~/ 16) % 16] + DIGITS[byte % 16]; |
| +} |