Coder Social home page Coder Social logo

msgpack-js-browser's Introduction

msgpack for the browser

Build Status

A handwritten msgpack encoder and decoder for Browsers

This is a browser port of https://github.com/creationix/msgpack-js

The original format can be found at http://wiki.msgpack.org/display/MSGPACK/Format+specification

Extension

I've extended the format a little to allow for encoding and decoding of undefined.

This required a new type code that is marked as "ext format". This change means that using these new types will render your serialized data incompatible with other messagepack implementations that don't have the same extension.

I've added a type for undefined that works just like the null type.

undefined  11010100  0xd4

Usage

require(['msgpack'], function (msgpack) {

  var initial = {Hello: "World"};
  var encoded = msgpack.encode(initial);
  var decoded = msgpack.decode(encoded);

});

msgpack-js-browser's People

Contributors

ambrusc avatar coverslide avatar creationix avatar hereismass avatar kkruups avatar ralphtheninja avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

msgpack-js-browser's Issues

Unpacking packed data from string

Seems like msgpack.decode assumes the encoded data is an instance of ArrayBuffer. Is there a way to unpack a JS string object containing packed data ? For example:

var packed = "\x81\xA3foo\xA3bar";
msgpack.unpack(packed); // => {foo: 'bar'}

msgpack 5 update

Hi Tim,
Thanks for sharing this code. I think it is still the one that can be used on client side (in terms of size and speed). I am using it on an online lua repl in combination with lua-MessagePack (spec 5). Long story short, I have updated your msgpack-js-browser according to msgpack 5 spec. (one can send binary strings from server side by lua-MessagePack and receive binary strings without utf-8 conversion, lua-MessagePack is quite flexible by the way). So, if you would like to update your code I can gladly send a pull request.

Regards
Ali

Simple Decode Example Not Working

I have yet to be able to get msgpack-python and msgpack-js-browser to talk. For the most part decoding of messages seems to go ok from server-client with some quirks. Sending messages to the server using msgpack-js-browser is having problems though.

To go a step further msgpack-js-browser seems to have issues decoding messages that it encoded. Small example:

var x = "1af60c36-497c-46cb-8408-78cab2a54a5b"; 
var encoded = msgpack.encode(x);
var decoded = msgpack.decode(encoded);  // ERROR
console.log(decoded);

I have seen both "Invalid byte a5" and "Uncaught RangeError: Offset is outside the bounds of the DataView"

Is there something I'm doing wrong here?

Can I use this in prod?

At 8hoot, we have all our APIs in MsgPack. This was good as we have a mobile app. However, we are developing a web app and it was hard to find a good MsgPack project to go with. Can you share your perspective on using this in prod web app?

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.