msgpack 0.9.0

  • README.md
  • Example
  • Installing
  • Versions
  • 13

MsgPack for Dart

A full-featured MsgPack library for Dart.

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);
}

example/example.dart

import "package:msgpack/msgpack.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 = pack(data);
  Map unpacked = unpack(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:
  msgpack: ^0.9.0

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:msgpack/msgpack.dart';
  
Version Uploaded Documentation Archive
0.9.0 Jun 13, 2018 Go to the documentation of msgpack 0.9.0 Download msgpack 0.9.0 archive
0.8.0+1 Feb 20, 2018 Go to the documentation of msgpack 0.8.0+1 Download msgpack 0.8.0+1 archive
0.8.0 Jun 28, 2016 Go to the documentation of msgpack 0.8.0 Download msgpack 0.8.0 archive
0.7.2 Jun 25, 2016 Go to the documentation of msgpack 0.7.2 Download msgpack 0.7.2 archive
0.7.1 Jun 25, 2016 Go to the documentation of msgpack 0.7.1 Download msgpack 0.7.1 archive
0.7.0 Jun 25, 2016 Go to the documentation of msgpack 0.7.0 Download msgpack 0.7.0 archive
0.6.0 Jun 25, 2016 Go to the documentation of msgpack 0.6.0 Download msgpack 0.6.0 archive
0.5.0 Jun 21, 2016 Go to the documentation of msgpack 0.5.0 Download msgpack 0.5.0 archive
0.4.0 Feb 12, 2016 Go to the documentation of msgpack 0.4.0 Download msgpack 0.4.0 archive
0.3.0 Jan 24, 2016 Go to the documentation of msgpack 0.3.0 Download msgpack 0.3.0 archive

All 12 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
26
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
13
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Health issues and suggestions

Document public APIs (-9.86 points)

68 out of 69 API elements (library, class, field or method) have no adequate dartdoc content. Good documentation improves code readability and discoverability through search.

Fix lib/msgpack.dart. (-0.50 points)

Analysis of lib/msgpack.dart reported 1 hint:

line 10 col 12: The top level variable '_isJavaScript' isn't used.

Format lib/src/packer.dart.

Run dartfmt to format lib/src/packer.dart.

Format lib/src/unpacker.dart.

Run dartfmt to format lib/src/unpacker.dart.

Maintenance issues and suggestions

Add SDK constraint in pubspec.yaml. (-50 points)

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Dependencies

Package Constraint Resolved Available
Dev dependencies
test ^0.12.0