Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kseo/tap
Ruby's Object#tap for Dart
https://github.com/kseo/tap
Last synced: 27 days ago
JSON representation
Ruby's Object#tap for Dart
- Host: GitHub
- URL: https://github.com/kseo/tap
- Owner: kseo
- License: bsd-3-clause
- Created: 2015-11-22T14:24:07.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-09T04:42:55.000Z (almost 9 years ago)
- Last Synced: 2023-08-20T23:21:33.452Z (about 1 year ago)
- Language: Dart
- Homepage: https://pub.dartlang.org/packages/tap
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# tap
This package provides Ruby's [Object#tap method][tap] for Dart.
[![Build Status](https://travis-ci.org/kseo/tap.svg)](https://travis-ci.org/kseo/tap)
[![Coverage Status](https://coveralls.io/repos/kseo/tap/badge.svg?branch=master&service=github)](https://coveralls.io/github/kseo/tap?branch=master)[tap]: http://ruby-doc.org/core-2.2.3/Object.html#method-i-tap
## Usage
The primary purpose of this method is to “tap into” a method chain,
in order to perform operations on intermediate results within the chain.```dart
import 'package:quiver_collection/collection.dart';
import 'package:tap/tap.dart';List gen(int n) => new List.generate(n, (i) => i);
class MyList extends DelegatingList with TapMixin> {
final List _base = new List();@override
List get delegate => _base;@override
String toString() => _base.toString();
}main() {
final xs = new MyList()..addAll(gen(10));
xs
..tap((xs) => print('original: $xs'))
..removeWhere((x) => x % 2 == 0)
..tap((xs) => print('removed: $xs'))
..shuffle()
..tap((xs) => print('shuffled: $xs'))
..sort()
..tap((xs) => print('sorted: $xs'));
// original: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
// removed: [1, 3, 5, 7, 9]
// shuffled: [3, 1, 7, 9, 5] (can differ)
// sorted: [1, 3, 5, 7, 9]
}
```## Features and bugs
Please file feature requests and bugs at the [issue tracker][tracker].
[tracker]: https://github.com/kseo/tap/issues