msgpack2 2.0.0+1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 73

MsgPack for Dart

Build Status

A full-featured MsgPack library for Dart 1.x and 2.x.

Attribution

This package was originally forked from msgpack. Due to the number of incompatible refactorings and loss of backwards compatibility, the decision was made to spin it off as a new package. This package contains numerous enhancements over the original MsgPack implementation which should help with performance in many places (see benchmarks), as well as a more complete testing suite.

Usage

Because this project relies on Dart Libraries which contain inconsistencies between Dart 1.x and Dart 2.x, there are two versions of the this package maintained.

If you want to use this package for Dart projects with Dart 2.x, please ensure your version dependencies are set to:

  dependencies:
    msgpack2: ^2.0.0

If you want to use this package for Dart projects with Dart 1.x, please ensure your version dependencies are set to:

  dependencies:
    msgpack2: ^1.0.0

Simple Example

import "dart:typed_data";

import "package:msgpack/msgpack.dart";

main() {
  var binary = new Uint8List.fromList(
    new List<int>.generate(40, (int i) => i)
  ).buffer.asByteData();

  var data = {
    "String": "Hello World",
    "Integer": 42,
    "Double": 45.29,
    "Integer List": [1, 2, 3],
    "Binary": binary,
    "Map": {
      1: 2,
      3: 4
    }
  };

  List<int> packed = pack(data);
  Map unpacked = unpack(packed);

  print(unpacked);
}

2.0.0

  • v2.0.0+1 - Update some metadata for the package.
  • v2.0.0 - Initial release for Dart 2.x.

1.0.0

  • v1.0.0+1 - Update some metadata for the package.
  • v1.0.0 - Initial release for Dart 1.x.

example/example.dart

import "package:msgpack2/msgpack2.dart";

import "dart:typed_data";
import "dart:math";

main() {
  var byteList = new Uint8List(1024 * 1024 * 20);
  var random = new Random();
  for (var i = 0; i < byteList.lengthInBytes; i++) {
    byteList[i] = random.nextInt(255);
  }
  var byteData = byteList.buffer
      .asByteData(byteList.offsetInBytes, byteList.lengthInBytes);

  var data = {
    "String": "Hello World",
    "Integer": 42,
    "Double": 45.29,
    "Integer List": [1, 2, 3],
    "Map": {1: 2, 3: 4},
    "Large Number": 1455232609379,
    "Negative Large Number": -1455232609379,
    "Simple Negative": -59,
    "Bytes": byteData,
    "Uint16": 65235
  };

  List<int> packed = serialize(data);
  Map unpacked = deserialize(packed);

  print("Original: $data");
  print("Unpacked: $unpacked");

  ByteData gotByteData = unpacked["Bytes"];

  if (gotByteData.lengthInBytes != byteData.lengthInBytes) {
    throw "Byte data is not the correct amount of bytes.";
  }

  for (var i = 0; i < gotByteData.lengthInBytes; i++) {
    if (byteData.getUint8(i) != gotByteData.getUint8(i)) {
      throw "Byte data is not the correct content.";
    }
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  msgpack2: ^2.0.0+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:msgpack2/msgpack2.dart';
  
Version Uploaded Documentation Archive
2.0.0+1 Nov 5, 2018 Go to the documentation of msgpack2 2.0.0+1 Download msgpack2 2.0.0+1 archive
2.0.0 Sep 13, 2018 Go to the documentation of msgpack2 2.0.0 Download msgpack2 2.0.0 archive
1.0.0+1 Nov 5, 2018 Go to the documentation of msgpack2 1.0.0+1 Download msgpack2 1.0.0+1 archive
1.0.0 Sep 13, 2018 Go to the documentation of msgpack2 1.0.0 Download msgpack2 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
50
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
73
Learn more about scoring.

We analyzed this package on Nov 14, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.6

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:msgpack2/msgpack2.dart.

Maintenance suggestions

The description is too long. (-10 points)

Search engines will display only the first part of the description. Try to keep it under 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
test ^1.3.0