Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Add extension method for easy creation #11

Merged
merged 5 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: dart
dart:
- dev
- 2.5.0
- stable
# Only building master means that we don't run two builds for each pull request.
dart_task:
- test: --platform vm,chrome
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 0.4.0

* Added an extension method on `String` to allow easy access to the `Characters`
of the string:

```dart
print('The first character is: ' + myString.characters.take(1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be .first instead of .take(1). The latter returns a Characters, not a String, and Characters cannot be added to a string.
(Would work if you use string interpolation instead of + because the Characters toString returns the string).

```

* Updated Dart SDK dependency to Dart 2.6.0

## 0.3.1

* Added small example in `example/main.dart`
Expand Down
1 change: 1 addition & 0 deletions lib/characters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
library characters;

export "src/characters.dart";
export "src/extensions.dart";
10 changes: 10 additions & 0 deletions lib/src/extensions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2019, 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.

import 'characters.dart';
mit-mit marked this conversation as resolved.
Show resolved Hide resolved

extension StringCharacters on String {
/// The [Characters] of this string.
Characters get characters => Characters(this);
}
5 changes: 2 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: characters
version: 0.3.1
version: 0.4.0
description: String replacement with operations that are Unicode/grapheme cluster aware.
author: Dart Team <[email protected]>
homepage: https://www.github.com/dart-lang/characters

environment:
sdk: ">=2.5.0 <3.0.0"
sdk: ">=2.6.0 <3.0.0"
dev_dependencies:
test: "^1.6.0"
pedantic: