Skip to content

Commit 16f396f

Browse files
authored
Merge pull request #134 from dart-lang/merge-convert-package
Merge `package:convert`
2 parents 17d1b2c + cbf9a16 commit 16f396f

35 files changed

+3136
-0
lines changed

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
- changed-files:
55
- any-glob-to-any-file: 'pkgs/args/**'
66

7+
"package:convert":
8+
- changed-files:
9+
- any-glob-to-any-file: 'pkgs/convert/**'
10+
711
"package:crypto":
812
- changed-files:
913
- any-glob-to-any-file: 'pkgs/crypto/**'

.github/workflows/convert.yaml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: package:convert
2+
3+
on:
4+
# Run CI on pushes to the main branch, and on PRs against main.
5+
push:
6+
branches: [ main ]
7+
paths:
8+
- '.github/workflows/convert.yaml'
9+
- 'pkgs/convert/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- '.github/workflows/convert.yaml'
14+
- 'pkgs/convert/**'
15+
schedule:
16+
- cron: "0 0 * * 0"
17+
env:
18+
PUB_ENVIRONMENT: bot.github
19+
20+
defaults:
21+
run:
22+
working-directory: pkgs/convert/
23+
24+
jobs:
25+
# Check code formatting and static analysis on a single OS (linux)
26+
# against Dart dev.
27+
analyze:
28+
runs-on: ubuntu-latest
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
sdk: [dev]
33+
steps:
34+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
35+
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
36+
with:
37+
sdk: ${{ matrix.sdk }}
38+
- id: install
39+
name: Install dependencies
40+
run: dart pub get
41+
- name: Check formatting
42+
run: dart format --output=none --set-exit-if-changed .
43+
if: always() && steps.install.outcome == 'success'
44+
- name: Analyze code
45+
run: dart analyze --fatal-infos
46+
if: always() && steps.install.outcome == 'success'
47+
48+
# Run tests on a matrix consisting of two dimensions:
49+
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
50+
# 2. release sdk: dev
51+
test:
52+
needs: analyze
53+
runs-on: ${{ matrix.os }}
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
# Add macos-latest and/or windows-latest if relevant for this package.
58+
os: [ubuntu-latest]
59+
sdk: [3.4, dev]
60+
steps:
61+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
62+
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
63+
with:
64+
sdk: ${{ matrix.sdk }}
65+
- id: install
66+
name: Install dependencies
67+
run: dart pub get
68+
- name: Run VM tests
69+
run: dart test --platform vm
70+
if: always() && steps.install.outcome == 'success'
71+
- name: Run Chrome tests
72+
run: dart test --platform chrome
73+
if: always() && steps.install.outcome == 'success'
74+
- name: Run Chrome tests - wasm
75+
run: dart test --platform chrome --compiler dart2wasm
76+
if: always() && steps.install.outcome == 'success'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ This repository is home to various Dart packages under the [dart.dev](https://pu
99
| Package | Description | Version |
1010
|---|---|---|
1111
| [args](pkgs/args/) | Library for defining parsers for parsing raw command-line arguments into a set of options and values. | [![pub package](https://img.shields.io/pub/v/args.svg)](https://pub.dev/packages/args) |
12+
| [convert](pkgs/convert/) | Utilities for converting between data representations. | [![pub package](https://img.shields.io/pub/v/convert.svg)](https://pub.dev/packages/convert) |
1213
| [crypto](pkgs/crypto/) | Implementations of SHA, MD5, and HMAC cryptographic functions. | [![pub package](https://img.shields.io/pub/v/crypto.svg)](https://pub.dev/packages/crypto) |
1314
| [fixnum](pkgs/fixnum/) | Library for 32- and 64-bit signed fixed-width integers. | [![pub package](https://img.shields.io/pub/v/fixnum.svg)](https://pub.dev/packages/fixnum) |
1415

pkgs/convert/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.dart_tool
2+
.packages
3+
pubspec.lock

pkgs/convert/AUTHORS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the project. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Google Inc.

pkgs/convert/CHANGELOG.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
## 3.1.2
2+
3+
- Require Dart 3.4
4+
- Add chunked decoding support (`startChunkedConversion`) for `CodePage`
5+
encodings.
6+
- Upper-cast the return type of the decoder from `List<int>` to `Uint8List`.
7+
- Move to `dart-lang/core` monorepo.
8+
9+
## 3.1.1
10+
11+
- Require Dart 2.18
12+
- Fix a number of comment references.
13+
14+
## 3.1.0
15+
16+
- Add a fixed-pattern DateTime formatter. See
17+
[#210](https://github.com/dart-lang/intl/issues/210) in package:intl.
18+
19+
## 3.0.2
20+
21+
- Fix bug in `CodePage` class. See issue
22+
[#47](https://github.com/dart-lang/convert/issues/47).
23+
24+
## 3.0.1
25+
26+
- Dependency clean-up.
27+
28+
## 3.0.0
29+
30+
- Stable null safety release.
31+
- Added `CodePage` class for single-byte `Encoding` implementations.
32+
33+
## 2.1.1
34+
35+
- Fixed a DDC compilation regression for consumers using the Dart 1.x SDK that
36+
was introduced in `2.1.0`.
37+
38+
## 2.1.0
39+
40+
- Added an `IdentityCodec<T>` which implements `Codec<T,T>` for use as default
41+
value for in functions accepting an optional `Codec` as parameter.
42+
43+
## 2.0.2
44+
45+
- Set max SDK version to `<3.0.0`, and adjust other dependencies.
46+
47+
## 2.0.1
48+
49+
- `PercentEncoder` no longer encodes digits. This follows the specified
50+
behavior.
51+
52+
## 2.0.0
53+
54+
**Note**: No new APIs have been added in 2.0.0. Packages that would use 2.0.0 as
55+
a lower bound should use 1.0.0 instead—for example, `convert: ">=1.0.0 <3.0.0"`.
56+
57+
- `HexDecoder`, `HexEncoder`, `PercentDecoder`, and `PercentEncoder` no longer
58+
extend `ChunkedConverter`.
59+
60+
## 1.1.1
61+
62+
- Fix all strong-mode warnings.
63+
64+
## 1.1.0
65+
66+
- Add `AccumulatorSink`, `ByteAccumulatorSink`, and `StringAccumulatorSink`
67+
classes for providing synchronous access to the output of chunked converters.
68+
69+
## 1.0.1
70+
71+
- Small improvement in percent decoder efficiency.
72+
73+
## 1.0.0
74+
75+
- Initial version

pkgs/convert/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2015, the Dart project authors.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of Google LLC nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pkgs/convert/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[![Dart CI](https://github.com/dart-lang/core/actions/workflows/convert.yaml/badge.svg)](https://github.com/dart-lang/core/actions/workflows/convert.yaml)
2+
[![pub package](https://img.shields.io/pub/v/convert.svg)](https://pub.dev/packages/convert)
3+
[![package publisher](https://img.shields.io/pub/publisher/convert.svg)](https://pub.dev/packages/convert/publisher)
4+
5+
Contains encoders and decoders for converting between different
6+
data representations. It's the external counterpart of the
7+
[`dart:convert`](https://api.dart.dev/dart-convert/dart-convert-library.html)
8+
SDK library, and contains less-central APIs and APIs that need more flexible
9+
versioning.

pkgs/convert/analysis_options.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# https://dart.dev/guides/language/analysis-options
2+
include: package:dart_flutter_team_lints/analysis_options.yaml
3+
4+
analyzer:
5+
language:
6+
strict-casts: true
7+
strict-raw-types: true
8+
9+
linter:
10+
rules:
11+
- avoid_private_typedef_functions
12+
- avoid_redundant_argument_values
13+
- avoid_unused_constructor_parameters
14+
- avoid_void_async
15+
- cancel_subscriptions
16+
- literal_only_boolean_expressions
17+
- missing_whitespace_between_adjacent_strings
18+
- no_adjacent_strings_in_list
19+
- no_runtimeType_toString
20+
- package_api_docs
21+
- prefer_const_declarations
22+
- prefer_expression_function_bodies
23+
- unnecessary_await_in_return
24+
- use_string_buffers
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
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.
4+
5+
import 'package:benchmark_harness/benchmark_harness.dart';
6+
import 'package:convert/convert.dart';
7+
8+
/// Test the performance of [FixedDateTimeFormatter.decode].
9+
class DecodeBenchmark extends BenchmarkBase {
10+
final fixedDateTimeFormatter = FixedDateTimeFormatter('YYYYMMDDhhmmss');
11+
DecodeBenchmark() : super('Parse 10k strings to DateTime');
12+
13+
@override
14+
void run() {
15+
for (var i = 0; i < 10000; i++) {
16+
fixedDateTimeFormatter.decode('19960425050322');
17+
}
18+
}
19+
}
20+
21+
void main() {
22+
DecodeBenchmark().report();
23+
}

0 commit comments

Comments
 (0)