Coder Social home page Coder Social logo

renggli / dart-more Goto Github PK

View Code? Open in Web Editor NEW
85.0 4.0 7.0 1.95 MB

More Dart — Literally.

Home Page: http://pub.dartlang.org/packages/more

License: MIT License

Dart 99.92% HTML 0.08%
dart collection iterable cache matcher math ordering formatter utilities library flutter printer functional async

dart-more's Introduction

More Dart — Literally

Pub Package Build Status Code Coverage GitHub Issues GitHub Forks GitHub Stars GitHub License

A collection of extensively tested extensions that make Dart a better place:

Library Description
async Extensions to Stream.
cache Caching strategies and their expiry policy.
char_matcher Character classes, their composition, and operations on strings.
collection Extensions to Iterable and new collection types.
comparator Common comparators, and extensions to perform advanced operations.
diff Tools for comparing lists.
feature Information about the runtime environment.
functional Types and features known from functional programming.
graph Graph-theory objects and algorithms.
interval Continuous interval data type over a comparable type.
math Common mathematical functions.
number Number types: fraction, complex, quaternion.
printer Fluent interface to configure sophisticated formatter.
temporal Extensions to DateTime and Duration types.
tuple Tuple extension methods on generic records.

And there are more to come ...

This library is open source, stable and well tested. Development happens on GitHub. Feel free to report issues or create a pull-request there. General questions are best asked on StackOverflow.

The package is hosted on dart packages. Up-to-date class documentation is created with every release.

Misc

Installation

Follow the installation instructions on dart packages.

Import the all-including parent package:

import 'package:more/more.dart';

Or one or more of the specific packages into your Dart code:

import 'package:more/async.dart';
import 'package:more/cache.dart';
import 'package:more/char_matcher.dart';
import 'package:more/collection.dart';
import 'package:more/comparator.dart';
import 'package:more/diff.dart';
import 'package:more/feature.dart';
import 'package:more/functional.dart';
import 'package:more/graph.dart';
import 'package:more/interval.dart';
import 'package:more/math.dart';
import 'package:more/number.dart';
import 'package:more/printer.dart';
import 'package:more/temporal.dart';
import 'package:more/tuple.dart';

Contributing

The goal of the library is to provide a loose collection of carefully curated utilities that are not provided by the Dart standard library. All features must be well tested. New features must have significant advantages over alternatives, such as code reduction, readability improvement, speed increase, memory reduction, or improved accuracy. In case of doubt, consider filing a feature request before filing a pull request.

History

This library started in April 2013 as I was working through the puzzles of Project Euler and encountered some missing features in Dart. Over time the code grew and became more useful in many other places, so I created this reusable library.

Some parts of this library are inspired by similar APIs in Google Guava (Google core libraries for Java) and Apache Commons (a repository of reusable Java components).

License

The MIT License, see LICENSE.

dart-more's People

Contributors

renggli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dart-more's Issues

Always Nulls Last for Ascending or Descending sort

I am having trouble getting Ascending vs Descending sort working, always with nulls last. Imagine code like this:

    final orderingAsc = Ordering.natural<String>().nullsLast;
    final orderingDesc = Ordering.natural<String>().reversed.nullsLast;
...
              final sorter = sortAscending ? orderingAsc : orderingDesc;
              return sorter.compare(s1, s2);

I would expect null values ALWAYS to be at the BOTTOM -- then the non-null values will be sorted in Ascending or Descending order, depending on the sortAscending flag.

What am I doing wrong?

IntegerRange(10, 35, 10) isn't returning [10, 20, 30]

Hi Lukas, Long time no speak, hope you're doing well!

I love this library, but there seems to be an issue in the logic in IntegerRange for non-default step sizes. Sorry to be reporting this just after 3.9.0 got released 😄

Cheers, Michael

Multiset difference method should take Iterable<Object?> as argument

Multiset's difference function takes Iterable` which was fine before null safety. But with null safety this unnecessarily limits the uses.
For example

Multiset<E> diffSample<E>(Multiset<E> multiset, Iterable<E> iterable) =>  multiset.difference(iterable);

will fail unless you force E to extend from Object.

I guess this logic will apply to other collection related code, but did not search for them.

Python `range` equivalent

Does more have any Python range equivalent, i.e. a function returning an iterable from int start until int end, exclusive?

flutter pub get failing with More 3.7.0 and Flutter 3.0.2

  • Run flutter create hello_world
  • Add more: ^3.7.0 to the pubspec.yaml file
  • Run flutter pub get

Got the following error:

$ flutter pub get 
Because every version of flutter_test from sdk depends on meta 1.7.0 and more >=3.6.0 depends on meta ^1.8.0, flutter_test from sdk is incompatible with more >=3.6.0.
So, because hello_world depends on both more ^3.7.0 and flutter_test from sdk, version solving failed.
Running "flutter pub get" in hello_world...                             
pub get failed (1; So, because hello_world depends on both more ^3.7.0 and flutter_test from sdk, version solving failed.)

`printer/null.dart` breaks DDC builds

I'm using this package for the iterable extensions, but ran into an issue when trying to use it on web using webdev serve.

When running with development settings, I get the following error: Uncaught SyntaxError: Unexpected token 'null' (at bimap.sound.ddc.js:108:7). This is caused by dart-lang/sdk#39595, which apparently never caught the eyes of the Dart team enough to fix. The package works properly in webdev release builds.

When I cloned locally, renamed null.dart to null_printer.dart and made the other necessary changes, the package worked as intended.

why data class is hidden?

for example, class Indexed in package:more/src/iterable/indexed.dart can't be accessed from other package.
but I want to use class for generics just like indexed<E>(list).map((Indexed<E> item) {}
any solution?
thanks in advance.

Iterable<T> insertBetween(T element) on Iterable<T>

Hey guys, I made this:

extension InsertBetweenExtension<T> on Iterable<T> {
  Iterable<T> insertBetween(T element) {
    final result = expand(
      (item) => [
        item,
        element,
      ],
    );

    return result.take(result.length - 1);
  }
}

It is useful in Flutter to insert dividers or paddings between widgets when you can't use the ListView.separated constructor (Row, Column, SliverList, etc.).

Row(
  crossAxisAlignment: CrossAxisAlignment.start,
  children: products
    .map<Widget>(
      (id) => Expanded(
        child: id != null ? ProductTile(id: id) : SizedBox.shrink(),
      ),
    )
    .insertBetween(SizedBox(width: 8.0))
    .toList(),
) 

Can it be an interesting addition to this package?

IntegerRange(500).contains(1000) is true

configuration

Dart: 1.18
OS: Windows 10 (64-bit)
More version: 3.8.2

example code

import "package:more/collection.dart";

void main() {
	final range = IntegerRange(500);
	print(range.contains(1000)); // true
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.