Security News
TC39 Advances 10+ ECMAScript Proposals: Key Features to Watch
TC39 is meeting in Tokyo this week and they have approved nearly a dozen proposals to advance to the next stages.
This package provides an extensible CBOR encoder/decoder.
var CBOR = require('cbor-sync');
var encodedBuffer = CBOR.encode({hello: 'world'});
var decodedObject = CBOR.decode(encodedBuffer);
toCBOR()
Much like the toJSON()
method, which allows objects to provide a replacement representation for encoding, this package checks for a toCBOR()
method.
Note that this step happens after any semantic-tagging/-replacement step, so a custom semantic encoder will always override an objects built-in toCBOR()
method.
CBOR provides a limited set of basic types (similar to JSON), but provides semantic tagging (optional for both encoder/decoder) that lets you annotate parts of the data so they can be decoded appropriately.
Here is an example (from this module) for encoding Date objects as ISO strings:
// 0 is the CBOR semantic tag number for date/time strings: https://tools.ietf.org/html/rfc7049#section-2.4
CBOR.addSemanticEncode(0, function (data) {
if (data instanceof Date) {
return data.toISOString();
}
});
CBOR.addSemanticDecode(0, function (dateString) {
return new Date(dateString);
});
FAQs
CBOR encode/decode (synchronous, semantic, browser-compatible)
The npm package cbor-sync receives a total of 162,790 weekly downloads. As such, cbor-sync popularity was classified as popular.
We found that cbor-sync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
TC39 is meeting in Tokyo this week and they have approved nearly a dozen proposals to advance to the next stages.
Security News
Our threat research team breaks down two malicious npm packages designed to exploit developer trust, steal your data, and destroy data on your machine.
Security News
A senior white house official is urging insurers to stop covering ransomware payments, indicating possible stricter regulations to deter cybercrime.