msgpack 0.9.0

  • README.md
  • Example
  • Installing
  • Versions
  • 74

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]
66
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
55
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, web, other

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

Health suggestions

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

Maintain CHANGELOG.md. (-20 points)

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

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

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

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