You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cbor

Package Overview
Dependencies
Maintainers
3
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cbor

Encode and parse data in the Concise Binary Object Representation (CBOR) data format (RFC8949).

10.0.10
latest
Source
npmnpm
Version published
Weekly downloads
974K
15.95%
Maintainers
3
Weekly downloads
 
Created

What is cbor?

The 'cbor' npm package is used for encoding and decoding data in the Concise Binary Object Representation (CBOR) format. CBOR is a binary data serialization format that is designed to be small, fast, and suitable for constrained environments. It is often used in IoT, web, and mobile applications where efficiency is critical.

What are cbor's main functionalities?

Encoding Data

This feature allows you to encode JavaScript objects into CBOR format. The example demonstrates encoding a simple object asynchronously.

const cbor = require('cbor');
const data = { key: 'value' };
cbor.encodeAsync(data).then(encoded => {
  console.log(encoded);
});

Decoding Data

This feature allows you to decode CBOR data back into JavaScript objects. The example shows how to decode a CBOR-encoded buffer.

const cbor = require('cbor');
const encodedData = Buffer.from('a2616b65796576616c7565', 'hex');
cbor.decodeFirst(encodedData).then(decoded => {
  console.log(decoded);
});

Streaming Encoding

This feature supports streaming encoding, which is useful for handling large datasets or continuous data streams. The example demonstrates encoding data in a stream.

const cbor = require('cbor');
const stream = cbor.encodeStream();
stream.on('data', chunk => {
  console.log(chunk);
});
stream.write({ key: 'value' });
stream.end();

Streaming Decoding

This feature supports streaming decoding, which is useful for processing large or continuous CBOR data streams. The example shows how to decode data from a stream.

const cbor = require('cbor');
const stream = cbor.decodeStream();
stream.on('data', obj => {
  console.log(obj);
});
stream.write(Buffer.from('a2616b65796576616c7565', 'hex'));
stream.end();

Other packages similar to cbor

Keywords

coap

FAQs

Package last updated on 03 Aug 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.