msgpack 0.8.0

  • README.md
  • Example
  • Installing
  • Versions
  • 69

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.";
    }
  }
}

1. Depend on it

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


dependencies:
  msgpack: "^0.8.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 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.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
0.2.0 Dec 8, 2015 Go to the documentation of msgpack 0.2.0 Download msgpack 0.2.0 archive
0.0.4 Aug 7, 2014 Go to the documentation of msgpack 0.0.4 Download msgpack 0.0.4 archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 3, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
65 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
32 / 100
Overall score:
Weighted score of the above. [more]
69

Platforms

Detected platforms: Flutter, web, other

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

Suggestions

  • Maintain CHANGELOG.md.

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

  • The description is too short.

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

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

Dependencies

Package Constraint Resolved Available
Dev dependencies
test >=0.12.13