@jprochazk/cbor
Advanced tools
Comparing version 0.2.4 to 0.2.5
{ | ||
"name": "@jprochazk/cbor", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Partial implementation of RFC 7049 (CBOR)", | ||
@@ -24,2 +24,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/jest": "^26.0.3", | ||
"@typescript-eslint/eslint-plugin": "^3.2.0", | ||
@@ -32,6 +33,3 @@ "@typescript-eslint/parser": "^3.2.0", | ||
}, | ||
"homepage": "https://github.com/jprochazk/cbor", | ||
"dependencies": { | ||
"@types/jest": "^26.0.3" | ||
} | ||
"homepage": "https://github.com/jprochazk/cbor" | ||
} |
@@ -8,11 +8,41 @@ # cbor | ||
This library provides the [recommended API](http://cbor.io/impls.html) | ||
### Usage | ||
This library is meant for use in the browser, but will also work in Node. | ||
``` | ||
> npm install @jprochazk/cbor | ||
``` | ||
The API is very simple: | ||
```js | ||
import CBOR from "@jprochazk/cbor"; | ||
const json = { | ||
"key": "value", | ||
"another key": [ | ||
1, 2, 3 | ||
], | ||
"number": 3.141592653589793 | ||
"nulls are also encoded": null | ||
}; | ||
// ArrayBuffer(51) | ||
const encoded = CBOR.encode(json); | ||
// { "key": "value", "another key": [1, 2, 3], "number": 3.14159265359, "nulls are also encoded": null} | ||
const decoded = CBOR.decode(encoded); | ||
console.log(decoded.key); // value | ||
console.log(decoded.number); // 3.1415927410125732 | ||
``` | ||
You can also encode into a pre-allocated ArrayBuffer. | ||
```js | ||
// Allocate a 64 byte buffer | ||
const buffer = new ArrayBuffer(64); | ||
// Encode the data into this buffer | ||
const encoded = CBOR.encodeInto(data, buffer); | ||
``` | ||
### Notes | ||
@@ -26,4 +56,4 @@ | ||
- 16-bit float (IEEE754 binary16) | ||
- Numbers larger than 32 bit (and BigInt) | ||
- Integers larger than 32 bit (BigInt) | ||
These weren't required in my case, but if you need one or more of these features, submit an [issue](https://github.com/jprochazk/cbor/issues), and I'll implement it! :) |
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
42641
0
58
0
7
- Removed@types/jest@^26.0.3
- Removed@jest/types@26.6.2(transitive)
- Removed@types/istanbul-lib-coverage@2.0.6(transitive)
- Removed@types/istanbul-lib-report@3.0.3(transitive)
- Removed@types/istanbul-reports@3.0.4(transitive)
- Removed@types/jest@26.0.24(transitive)
- Removed@types/node@22.10.10(transitive)
- Removed@types/yargs@15.0.19(transitive)
- Removed@types/yargs-parser@21.0.3(transitive)
- Removedansi-regex@5.0.1(transitive)
- Removedansi-styles@4.3.0(transitive)
- Removedchalk@4.1.2(transitive)
- Removedcolor-convert@2.0.1(transitive)
- Removedcolor-name@1.1.4(transitive)
- Removeddiff-sequences@26.6.2(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedjest-diff@26.6.2(transitive)
- Removedjest-get-type@26.3.0(transitive)
- Removedpretty-format@26.6.2(transitive)
- Removedreact-is@17.0.2(transitive)
- Removedsupports-color@7.2.0(transitive)
- Removedundici-types@6.20.0(transitive)