@libp2p/record 2.0.1 → 2.0.3
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/dist/src/index.d.ts +1 -1
- package/dist/src/record.d.ts +2 -2
- package/dist/src/record.d.ts.map +1 -1
- package/dist/src/record.js +52 -6
- package/dist/src/record.js.map +1 -1
- package/package.json +5 -5
- package/src/record.ts +64 -8
package/dist/src/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class Libp2pRecord {
|
|
|
5
5
|
value: Uint8Array;
|
|
6
6
|
timeReceived: Date;
|
|
7
7
|
constructor(key: Uint8Array, value: Uint8Array, timeReceived: Date);
|
|
8
|
-
serialize():
|
|
8
|
+
serialize(): Uint8Array;
|
|
9
9
|
/**
|
|
10
10
|
* Return the object format ready to be given to the protobuf library.
|
|
11
11
|
*/
|
package/dist/src/record.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Codec } from 'protons-runtime';
|
|
2
1
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
2
|
+
import type { Codec } from 'protons-runtime';
|
|
3
3
|
export interface Record {
|
|
4
4
|
key: Uint8Array;
|
|
5
5
|
value: Uint8Array;
|
|
@@ -7,7 +7,7 @@ export interface Record {
|
|
|
7
7
|
}
|
|
8
8
|
export declare namespace Record {
|
|
9
9
|
const codec: () => Codec<Record>;
|
|
10
|
-
const encode: (obj: Record) =>
|
|
10
|
+
const encode: (obj: Record) => Uint8Array;
|
|
11
11
|
const decode: (buf: Uint8Array | Uint8ArrayList) => Record;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=record.d.ts.map
|
package/dist/src/record.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAE5C,MAAM,WAAW,MAAM;IACrB,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,UAAU,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,yBAAiB,MAAM,CAAC;IAGf,MAAM,KAAK,QAAO,MAAM,MAAM,CA0DpC,CAAA;IAEM,MAAM,MAAM,QAAS,MAAM,KAAG,UAEpC,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,GAAG,cAAc,KAAG,MAEzD,CAAA;CACF"}
|
package/dist/src/record.js
CHANGED
|
@@ -1,14 +1,60 @@
|
|
|
1
1
|
/* eslint-disable import/export */
|
|
2
|
+
/* eslint-disable complexity */
|
|
2
3
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
3
|
-
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
|
5
|
+
import { encodeMessage, decodeMessage, message } from 'protons-runtime';
|
|
4
6
|
export var Record;
|
|
5
7
|
(function (Record) {
|
|
8
|
+
let _codec;
|
|
6
9
|
Record.codec = () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
if (_codec == null) {
|
|
11
|
+
_codec = message((obj, w, opts = {}) => {
|
|
12
|
+
if (opts.lengthDelimited !== false) {
|
|
13
|
+
w.fork();
|
|
14
|
+
}
|
|
15
|
+
if (opts.writeDefaults === true || (obj.key != null && obj.key.byteLength > 0)) {
|
|
16
|
+
w.uint32(10);
|
|
17
|
+
w.bytes(obj.key);
|
|
18
|
+
}
|
|
19
|
+
if (opts.writeDefaults === true || (obj.value != null && obj.value.byteLength > 0)) {
|
|
20
|
+
w.uint32(18);
|
|
21
|
+
w.bytes(obj.value);
|
|
22
|
+
}
|
|
23
|
+
if (opts.writeDefaults === true || obj.timeReceived !== '') {
|
|
24
|
+
w.uint32(42);
|
|
25
|
+
w.string(obj.timeReceived);
|
|
26
|
+
}
|
|
27
|
+
if (opts.lengthDelimited !== false) {
|
|
28
|
+
w.ldelim();
|
|
29
|
+
}
|
|
30
|
+
}, (reader, length) => {
|
|
31
|
+
const obj = {
|
|
32
|
+
key: new Uint8Array(0),
|
|
33
|
+
value: new Uint8Array(0),
|
|
34
|
+
timeReceived: ''
|
|
35
|
+
};
|
|
36
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
37
|
+
while (reader.pos < end) {
|
|
38
|
+
const tag = reader.uint32();
|
|
39
|
+
switch (tag >>> 3) {
|
|
40
|
+
case 1:
|
|
41
|
+
obj.key = reader.bytes();
|
|
42
|
+
break;
|
|
43
|
+
case 2:
|
|
44
|
+
obj.value = reader.bytes();
|
|
45
|
+
break;
|
|
46
|
+
case 5:
|
|
47
|
+
obj.timeReceived = reader.string();
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
reader.skipType(tag & 7);
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return obj;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return _codec;
|
|
12
58
|
};
|
|
13
59
|
Record.encode = (obj) => {
|
|
14
60
|
return encodeMessage(obj, Record.codec());
|
package/dist/src/record.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,oDAAoD;
|
|
1
|
+
{"version":3,"file":"record.js","sourceRoot":"","sources":["../../src/record.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+BAA+B;AAC/B,oDAAoD;AACpD,8EAA8E;AAE9E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAUvE,MAAM,KAAW,MAAM,CAsEtB;AAtED,WAAiB,MAAM;IACrB,IAAI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2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "libp2p record implementation",
|
|
5
5
|
"author": "Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
@@ -168,14 +168,14 @@
|
|
|
168
168
|
"dependencies": {
|
|
169
169
|
"@libp2p/interface-dht": "^1.0.0",
|
|
170
170
|
"err-code": "^3.0.1",
|
|
171
|
-
"multiformats": "^
|
|
172
|
-
"protons-runtime": "^
|
|
171
|
+
"multiformats": "^10.0.0",
|
|
172
|
+
"protons-runtime": "^4.0.1",
|
|
173
173
|
"uint8arraylist": "^2.1.1",
|
|
174
|
-
"uint8arrays": "^
|
|
174
|
+
"uint8arrays": "^4.0.2"
|
|
175
175
|
},
|
|
176
176
|
"devDependencies": {
|
|
177
177
|
"@libp2p/crypto": "^1.0.2",
|
|
178
178
|
"aegir": "^37.0.13",
|
|
179
|
-
"protons": "^
|
|
179
|
+
"protons": "^6.0.0"
|
|
180
180
|
}
|
|
181
181
|
}
|
package/src/record.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/* eslint-disable import/export */
|
|
2
|
+
/* eslint-disable complexity */
|
|
2
3
|
/* eslint-disable @typescript-eslint/no-namespace */
|
|
4
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
|
3
5
|
|
|
4
|
-
import { encodeMessage, decodeMessage, message
|
|
5
|
-
import type { Codec } from 'protons-runtime'
|
|
6
|
+
import { encodeMessage, decodeMessage, message } from 'protons-runtime'
|
|
6
7
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
8
|
+
import type { Codec } from 'protons-runtime'
|
|
7
9
|
|
|
8
10
|
export interface Record {
|
|
9
11
|
key: Uint8Array
|
|
@@ -12,15 +14,69 @@ export interface Record {
|
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
export namespace Record {
|
|
17
|
+
let _codec: Codec<Record>
|
|
18
|
+
|
|
15
19
|
export const codec = (): Codec<Record> => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
if (_codec == null) {
|
|
21
|
+
_codec = message<Record>((obj, w, opts = {}) => {
|
|
22
|
+
if (opts.lengthDelimited !== false) {
|
|
23
|
+
w.fork()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (opts.writeDefaults === true || (obj.key != null && obj.key.byteLength > 0)) {
|
|
27
|
+
w.uint32(10)
|
|
28
|
+
w.bytes(obj.key)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (opts.writeDefaults === true || (obj.value != null && obj.value.byteLength > 0)) {
|
|
32
|
+
w.uint32(18)
|
|
33
|
+
w.bytes(obj.value)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (opts.writeDefaults === true || obj.timeReceived !== '') {
|
|
37
|
+
w.uint32(42)
|
|
38
|
+
w.string(obj.timeReceived)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (opts.lengthDelimited !== false) {
|
|
42
|
+
w.ldelim()
|
|
43
|
+
}
|
|
44
|
+
}, (reader, length) => {
|
|
45
|
+
const obj: any = {
|
|
46
|
+
key: new Uint8Array(0),
|
|
47
|
+
value: new Uint8Array(0),
|
|
48
|
+
timeReceived: ''
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const end = length == null ? reader.len : reader.pos + length
|
|
52
|
+
|
|
53
|
+
while (reader.pos < end) {
|
|
54
|
+
const tag = reader.uint32()
|
|
55
|
+
|
|
56
|
+
switch (tag >>> 3) {
|
|
57
|
+
case 1:
|
|
58
|
+
obj.key = reader.bytes()
|
|
59
|
+
break
|
|
60
|
+
case 2:
|
|
61
|
+
obj.value = reader.bytes()
|
|
62
|
+
break
|
|
63
|
+
case 5:
|
|
64
|
+
obj.timeReceived = reader.string()
|
|
65
|
+
break
|
|
66
|
+
default:
|
|
67
|
+
reader.skipType(tag & 7)
|
|
68
|
+
break
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return obj
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return _codec
|
|
21
77
|
}
|
|
22
78
|
|
|
23
|
-
export const encode = (obj: Record):
|
|
79
|
+
export const encode = (obj: Record): Uint8Array => {
|
|
24
80
|
return encodeMessage(obj, Record.codec())
|
|
25
81
|
}
|
|
26
82
|
|