Socket
Socket
Sign inDemoInstall

cbor-x

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cbor-x - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

2

dist/index.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.msgpackr = {}));
(global = global || self, factory(global.CBOR = {}));
}(this, (function (exports) { 'use strict';

@@ -6,0 +6,0 @@

@@ -1,2 +0,2 @@

(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.msgpackr={}))})(this,function(a){'use strict';function b(){let a=u[w++],d=a>>5;if(a&=31,23<a)switch(a){case 24:a=u[w++];break;case 25:if(7==d)return i();a=C.getUint16(w),w+=2;break;case 26:if(7==d){let a=C.getFloat32(w);if(2<D.useFloat32){// this does rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports):"function"==typeof define&&define.amd?define(["exports"],b):(a=a||self,b(a.CBOR={}))})(this,function(a){'use strict';function b(){let a=u[w++],d=a>>5;if(a&=31,23<a)switch(a){case 24:a=u[w++];break;case 25:if(7==d)return i();a=C.getUint16(w),w+=2;break;case 26:if(7==d){let a=C.getFloat32(w);if(2<D.useFloat32){// this does rounding of numbers that were encoded in 32-bit float to nearest significant decimal digit that could be preserved
let b=S[(127&u[w])<<1|u[w+1]>>7];return w+=4,(b*a+(0<a?.5:-.5)>>0)/b}return w+=4,a}a=C.getUint32(w),w+=4;break;case 27:if(7==d){let a=C.getFloat64(w);return w+=8,a}if(D.uint64AsNumber)return 72057594037927940*u[w++]+281474976710656*u[w++]+1099511627776*u[w++]+4294967296*u[w++]+16777216*u[w++]+(u[w++]<<16)+(u[w++]<<8)+u[w++];a=C.getBigUint64(w),w+=8;break;case 31:// indefinite length

@@ -3,0 +3,0 @@ switch(d){case 2:// byte string

{
"name": "cbor-x",
"author": "Kris Zyp",
"version": "0.8.0",
"version": "0.8.1",
"description": "Ultra-fast CBOR implementation with tag extensions for records and structured cloning",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -54,3 +54,3 @@ # cbor-x

## Deno Usage
Msgpackr modules are standard ESM modules and can be loaded directly from github (https://raw.githubusercontent.com/kriszyp/msgpackr/master/index.js) or downloaded and used directly in Deno. The standard pack/encode and unpack/decode functionality is available on Deno, like other platforms.
CBOR modules are standard ESM modules and can be loaded directly from github (https://raw.githubusercontent.com/kriszyp/cbor-x/master/index.js) or downloaded and used directly in Deno. The standard encode and decode functionality is available on Deno, like other platforms.

@@ -230,26 +230,3 @@ ## Browser Usage

```
If you want to use msgpackr to encode and decode the data within your extensions, you can use the `read` and `write` functions and read and write data/objects that will be encoded and decoded by msgpackr, which can be easier and faster than creating and receiving separate buffers (note that you can't just return the instance from `write` or msgpackr will recursively try to use extension infinitely):
```js
import { addExtension, Packr } from 'msgpackr';
class MyCustomClass {...}
let extPackr = new Packr();
addExtension({
Class: MyCustomClass,
type: 11, // register your own extension code (a type code from 1-100)
write(instance) {
// define how your custom class should be encoded
return instance.myData; // return some data to be encoded
}
read(data) {
// define how your custom class should be decoded,
// data will already be unpacked/decoded
let instance = new MyCustomClass();
instance.myData = data;
return instance; // return decoded value
}
});
```
## Unknown Tags

@@ -268,7 +245,4 @@ If no extension is registered for a tag, the decoder will return an instance of the `Tag` class, where the value provided for the tag will be available in the `value` property of the `Tag` instance. The `Tag` class is an export of the package and decode module.

## Extensions
Cbor-x currently uses tag ids 40000 to 40500 for its proposed extensions (until accepted).
Cbor-x currently uses tag id 105 and 26880-27135 for its [proposed extension for records](https://github.com/kriszyp/cbor-records).
## Record Structure Extension Definition
The record struction extension uses tag 40006 to declare a new record structure. This is followed by an array where the first element indicates the tag id of the record structure to declare and the next element is an array of the field names, and the third element is array of the property values. The extension declaration must be immediately follow by the field names of the record structure.
### Dates

@@ -282,3 +256,3 @@ cbor-x saves all JavaScript `Date`s using the standard CBOR date extension (tag 1).

The high-performance serialization and deserialization algorithms in this package are also available in the [msgpackr](https://github.com/kriszyp/msgpackr) for the MessagePack format, with the same API and design. A quick summary of the pros and cons of using MessagePack vs CBOR are:
* MessagePack has wider adoption, and, at least with this implementation is slightly more efficient (by roughly 2-4%).
* MessagePack has wider adoption, and, at least with this implementation is slightly more efficient (by roughly 2-4%, but YMMV).
* CBOR has an [official IETF standardization track](https://www.rfc-editor.org/rfc/rfc8949.html), and the record extensions is conceptually/philosophically a better fit for CBOR tags.

@@ -291,3 +265,3 @@

### Browser Consideration
CBOR can be a great choice for high-performance data delivery to browsers, as reasonable data size is possible without compression. And msgpackr works very well in modern browsers. However, it is worth noting that if you want highly compact data, brotli or gzip are most effective in compressing, and CBOR's character frequency tends to defeat Huffman encoding used by these standard compression algorithms, resulting in less compact data than compressed JSON.
CBOR can be a great choice for high-performance data delivery to browsers, as reasonable data size is possible without compression. And CBOR works very well in modern browsers. However, it is worth noting that if you want highly compact data, brotli or gzip are most effective in compressing, and CBOR's character frequency tends to defeat Huffman encoding used by these standard compression algorithms, resulting in less compact data than compressed JSON.

@@ -294,0 +268,0 @@ ### Credits

@@ -19,3 +19,3 @@ import minify from "rollup-plugin-babel-minify";

format: "umd",
name: "msgpackr"
name: "CBOR"
}

@@ -30,3 +30,3 @@ },

format: "umd",
name: "msgpackr"
name: "CBOR"
}

@@ -43,3 +43,3 @@ },

chai: 'chai',
'./index.js': 'msgpackr',
'./index.js': 'CBOR',
},

@@ -46,0 +46,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc