Code Monkey home page Code Monkey logo

qpack-js's Introduction

QPack JavaScript

Library for encoding and decoding QPack data using pure JavaScript.

Usage example:

var iris = {
  name: 'Iris',
  age: 3
};

// Encode iris to a binary string.
// The second argument is true which tells the function to return a string.
// When false or undefined an Uint8Array is returned.
var qp = qpack.encode(iris, true);

// Decode qp binary string to JavaScript object.
var data = qpack.decode(qp);

console.log(data);  // {name: 'Iris', age: 3}

Float problem

JavaScript has no integer type and therefore values like 1.0 and 1 are equal. QPack cannot known if such value should be packed as integer or as float. By default x.0 will be packed as integer x. Any other float like 1.2 will be packed as float. If you have a situation where you really want to pack a value as float, then wrap the value with the function qpack.double(f).

For example:

// This will pack 1.0 as a double (float) value.
var qp = qpack.encode(qpack.double(1.0), true);

qpack-js's People

Contributors

joente avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

qpack-js's Issues

QPack should be able to pack float values a double.

JavaScript has only float type and no integer values. Therefore QPack does not known when to pack a value as integer of as float. Sometimes this doesn't matter but in some cases you really want the type to be correct.

We can use a function to force packing a value as float.

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.