pmap 0.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 45

pmap #

Description #

A parallel implementation of Iterable.map. This is a convenient function to help parallelize expensive operations.

Example #

import 'package:pmap/pmap.dart';

int square(int x) => x * x;

void main() async {
  List<int> list = [1, 2, 3, 4, 5];
  Stream<int> results = pmap(list, square);
  await for (int value in results) {
    print(value);
  }
}

0.2.1 #

  • Added unit tests fixed error for parallel > 2

0.2.0 #

  • Made the results for parallel > 2 ordered.

0.1.0 #

  • Initial release - pmap results can be out of order for parallel > 1.

example/lib/main.dart

import 'package:pmap/pmap.dart';

int mapper(int x) => x * x;

Iterable<int> countTo(int x) sync* {
  for( int i = 0; i < x; ++i) {
    yield i;
  }
}

void main() async {
  Iterable<int> foo = countTo(100);
  Stream<int> results = pmap(foo, mapper, parallel: 2);
  await for (int value in results) {
    print(value);
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pmap: ^0.2.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pmap/pmap.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
45
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1

Analysis suggestions

Package not compatible with runtime flutter-web of web

Because of the import of dart:isolate via the import chain package:pmap/pmap.dart->dart:isolate

Package not compatible with runtime web

Because of the import of dart:isolate via the import chain package:pmap/pmap.dart->dart:isolate

Health suggestions

Fix lib/error.dart. (-1.99 points)

Analysis of lib/error.dart reported 4 hints:

line 4 col 21: Unnecessary new keyword.

line 6 col 23: The value of the local variable 'mapper' isn't used.

line 10 col 29: Unnecessary new keyword.

line 11 col 11: The value of the local variable 'isolate' isn't used.

Fix lib/pmap.dart. (-1 points)

Analysis of lib/pmap.dart reported 2 hints:

line 22 col 21: Unnecessary new keyword.

line 36 col 29: Unnecessary new keyword.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
Dev dependencies
test ^1.11.1