@jprochazk/cbor
Advanced tools
Comparing version 0.3.0 to 0.3.1
'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). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
123315
2892
64