GithubHelp home page GithubHelp logo

node-msgpack3's Introduction

msgpack3

A speedy implementation of the MessagePack serialization protocol, written from scratch in C++.

MessagePack offers significant advantages over other serialization protocols, such as JSON, as it encodes objects very compactly. For example, the following object:

var o = {
  a: {
    b: -123,
    c: 123
  },
  d: [
    "Augustine",
    "Emma",
    "Shai",
    "Leea"
  ]
};

Is packed into 39 bytes by msgpack3, and 63 bytes by the native JSON library. In this specific case, MessagePack was around 60% more space efficient. However, these kinds of savings are quite typical. In general, MessagePack messages are significantly more space efficient than JSON.

Performance

At the moment, this implementation of MessagePack is NOT faster than node's native JSON library. However, it is (marginally) faster than other msgpack libraries for node.js, such as [msgpack2](https://github.com/JulesAU/nod e-msgpack), at least in the benchmark I used (see bench/bench.js).

For specifics, see the TODO.md file.

Installation

It's on npm:

$ npm install msgpack3

Usage

msgpack3 provides two functions, pack and unpack which, respectively, serialize and deserialize javascript objects.

msgpack.pack(obj)

Takes a javascript object as input and returns a buffer.

msgpack.unpack(buf)

Takes a buffer as input and returns a javascript object.

See the source code for more details.

Example

var msgpack = require("msgpack3"),
    assert = require("assert);

var a = { a: 123, b: [1, 2, 3] }

var buf = msgpack.pack(o);

var b = msgpack.unpack(buf);

assert.deepEqual(a, b);

License

(The MIT License)

Copyright (C) 2012 by Siddharth Mahendraker

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

node-msgpack3's People

Stargazers

Angus H. avatar Cuyler Jones avatar Siddharth Mahendraker avatar tom zhou avatar jenny rakoczy avatar

Watchers

Siddharth Mahendraker avatar James Cloos avatar Dmitry N. Medvedev avatar

node-msgpack3's Issues

Does not compile on my Mac

At first I tried npm install msgpack3

Then I cloned https://github.com/siddMahen/node-msgpack3 and tried npm install

Still no joy. I looked into the compile and it seemed like src/msgpack.cc line 14 had the symbol FALSE, which
is defined in /usr/include/mach/boolean.h as 0 (no surprise). I tried to put a #ifdef #undef in msgpack.cc .

node-msgpack3 is simple straight forward code. I have no Idea what is going on.

FYI:
node v0.8.4

OSX Mountain Lion aka 10.8
XCode 4.4

$ uname -a
Darwin alterside.local 12.0.0 Darwin Kernel Version 12.0.0: Sun Jun 24 23:00:16 PDT 2012; root:xnu-2050.7.9~1/RELEASE_X86_64 x86_64

$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.