cbor-x 1.3.3 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +347 -346
- package/SECURITY.md +11 -11
- package/benchmark.md +73 -73
- package/browser.js +11 -11
- package/decode.d.ts +2 -46
- package/decode.js +9 -7
- package/dist/index.js +1122 -1112
- package/dist/index.min.js +86 -76
- package/dist/node.cjs +1190 -1180
- package/dist/test.js +17 -1
- package/encode.d.ts +1 -6
- package/encode.js +1041 -1033
- package/index.d.ts +61 -12
- package/index.js +3 -3
- package/iterators.js +85 -85
- package/node-index.js +24 -24
- package/package.json +6 -1
- package/rollup.config.js +45 -45
- package/stream.js +57 -57
- package/webpack.config.js +19 -19
- package/dist/index.js.map +0 -1
- package/dist/node-index.js +0 -93
package/dist/test.js
CHANGED
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
var ITERATIONS = 4000;
|
|
44
44
|
|
|
45
45
|
suite('CBOR basic tests', function(){
|
|
46
|
-
|
|
47
46
|
test('encode/decode with keyMaps (basic)', function() {
|
|
48
47
|
var data = senmlData;
|
|
49
48
|
let cborSenml = new Encoder({ useRecords: false, keyMap: senmlKeys });
|
|
@@ -559,6 +558,17 @@
|
|
|
559
558
|
assert.deepEqual(deserialized, data);
|
|
560
559
|
});
|
|
561
560
|
|
|
561
|
+
test('encode ArrayBuffer', function() {
|
|
562
|
+
let ua = new Uint8Array([3, 4, 5]);
|
|
563
|
+
let encoded = encode(ua.buffer);
|
|
564
|
+
let decoded = decode(encoded);
|
|
565
|
+
assert.equal(decoded[0], 3);
|
|
566
|
+
assert.equal(decoded[0], 3);
|
|
567
|
+
assert.equal(decoded[1], 4);
|
|
568
|
+
assert.equal(decoded[2], 5);
|
|
569
|
+
assert.equal(decoded.byteLength, 3);
|
|
570
|
+
});
|
|
571
|
+
|
|
562
572
|
test('iterator/indefinite length array', function(){
|
|
563
573
|
class NotArray {
|
|
564
574
|
}
|
|
@@ -599,6 +609,12 @@
|
|
|
599
609
|
var serialized = encode(data);
|
|
600
610
|
var deserialized = decode(serialized);
|
|
601
611
|
assert.deepEqual(deserialized, data);
|
|
612
|
+
let encoder = new Encoder({ tagUint8Array: true });
|
|
613
|
+
serialized = encoder.encode(new Uint8Array([2,3,4]));
|
|
614
|
+
assert.equal(serialized[0], 0xd8);
|
|
615
|
+
encoder = new Encoder({ tagUint8Array: false });
|
|
616
|
+
serialized = encoder.encode(new Uint8Array([2,3,4]));
|
|
617
|
+
assert.equal(serialized[0], 0x43);
|
|
602
618
|
});
|
|
603
619
|
|
|
604
620
|
test('noteencode test', function() {
|
package/encode.d.ts
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { addExtension, FLOAT32_OPTIONS } from './decode'
|
|
3
|
-
export class Encoder extends Decoder {
|
|
4
|
-
encode(value: any): Buffer
|
|
5
|
-
}
|
|
6
|
-
export function encode(value: any): Buffer
|
|
1
|
+
export { encode, Encoder, addExtension, FLOAT32_OPTIONS } from '.'
|