Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jprochazk/cbor

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jprochazk/cbor - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

4

dist/index.cjs.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
/*! *****************************************************************************

@@ -917,2 +915,2 @@ Copyright (c) Microsoft Corporation.

exports.CBOR = CBOR;
module.exports = CBOR;

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

export declare class CBOR {
export default class CBOR {
/**

@@ -3,0 +3,0 @@ * Decodes a CBOR object into JSON

@@ -913,2 +913,2 @@ /*! *****************************************************************************

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

@@ -919,6 +919,4 @@ /*! *****************************************************************************

exports.CBOR = CBOR;
return CBOR;
Object.defineProperty(exports, '__esModule', { value: true });
})));
{
"name": "@jprochazk/cbor",
"version": "0.3.0",
"version": "0.3.1",
"description": "Partial implementation of RFC 7049 (CBOR)",

@@ -5,0 +5,0 @@ "author": "Jan Procházka",

@@ -16,7 +16,7 @@ # cbor

The API is very simple:
The API is self-explanatory:
```js
import CBOR from "cbor";
// Initialize some data
const json = {

@@ -31,11 +31,7 @@ "key": "value",

const encoded = CBOR.encode(json);
const decoded = CBOR.decode(encoded);
```
const encoded = CBOR.encode(json); // ArrayBuffer
const decoded = CBOR.decode(encoded); // { ... }
You can also encode into a pre-allocated buffer.
```js
// Allocate a 4KiB buffer
// You can also encode into a pre-allocated buffer
const buffer = new ArrayBuffer(4096);
// Encode the data into this buffer
const encoded = CBOR.encodeInto(data, buffer);

@@ -51,5 +47,5 @@ ```

| :------- | :---------- | :-------------- | :---------- |
| i5-8600K | 0.6555 ms | 0.5743 ms | 1.1312 ms |
| i5-8600K | 0.6535 ms | 0.5743 ms | 1.0312 ms |
The JSON object used is ~13KB decoded, ~6KB encoded. This means ~13MB/s decoding speed and ~10MB/s encoding speed.
The JSON data used in the test is 13 KB decoded and 6 KB encoded. This means the library can decode at 13 MB/s and encode at 10 MB/s.

@@ -60,3 +56,3 @@ You can squeeze out a bit more performance if you use `CBOR.encodeInto` with a sufficiently large buffer. the `CBOR.encode` default is 1024 bytes, which should be enough for the vast majority of uses, but if you ever find yourself using more than that, utilize `CBOR.encodeInto`.

This library is meant for use in the browser. Node support is in the works.
This library is supported for use in both Node & browsers.

@@ -71,2 +67,2 @@ There are a few things from the specification which are currently unimplemented:

These weren't required in my case, but they're trivial additions to the existing parser/writer logic. If you need one or more of these features, submit an [issue](https://github.com/jprochazk/cbor/issues).
If you need one or more of these features, submit an [issue](https://github.com/jprochazk/cbor/issues).
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