Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@jprochazk/cbor
Advanced tools
JavaScript implementation of the CBOR RFC 7049.
> npm install cbor@npm:jprochazk/cbor
The above command will install the library under the cbor
alias.
The API is self-explanatory:
import CBOR from "cbor";
// Initialize some data
const json = {
"key": "value",
"another key": [
1, 2, 3
],
"number": 3.141592653589793
"nulls are also encoded": null
};
const encoded = CBOR.encode(json); // ArrayBuffer
const decoded = CBOR.decode(encoded); // { ... }
// You can also encode into a pre-allocated buffer
const buffer = new ArrayBuffer(4096);
const encoded = CBOR.encodeInto(data, buffer);
Speed was one of my main concerns when writing this library. Benchmark is available here.
Browser | CBOR.decode | CBOR.encode | CBOR.encodeInto |
---|---|---|---|
Chrome | 5225 ops/s | 8998 ops/s | 9268 ops/s |
Firefox | 20454 ops/s | 22323 ops/s | 22900 ops/s |
Results are on a i5-8600k intel processor. The JSON data used in the test is 2 KB decoded and 1.8 KB encoded. This means the library can decode at 13 MB/s and encode at 10 MB/s in Chrome, and around 2.5~4x as much in Firefox.
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 both Node & browsers. Minimum supported Node version is 11.
There are a few things from the specification which are currently unimplemented:
If you need one or more of these features, submit an issue.
FAQs
Partial implementation of RFC 7049 (CBOR)
The npm package @jprochazk/cbor receives a total of 84 weekly downloads. As such, @jprochazk/cbor popularity was classified as not popular.
We found that @jprochazk/cbor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.