@libp2p/pubsub 6.0.3 → 6.0.4
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/index.min.js +1 -1
- package/dist/src/index.d.ts +2 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +16 -12
- package/dist/src/index.js.map +1 -1
- package/dist/src/peer-streams.d.ts.map +1 -1
- package/dist/src/peer-streams.js +1 -1
- package/dist/src/peer-streams.js.map +1 -1
- package/dist/src/sign.d.ts.map +1 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js.map +1 -1
- package/package.json +4 -6
- package/src/index.ts +35 -31
- package/src/peer-streams.ts +7 -7
- package/src/sign.ts +2 -2
- package/src/utils.ts +4 -4
package/src/utils.ts
CHANGED
@@ -17,7 +17,7 @@ export function randomSeqno (): bigint {
|
|
17
17
|
/**
|
18
18
|
* Generate a message id, based on the `key` and `seqno`
|
19
19
|
*/
|
20
|
-
export const msgId = (key: Uint8Array, seqno: bigint) => {
|
20
|
+
export const msgId = (key: Uint8Array, seqno: bigint): Uint8Array => {
|
21
21
|
const seqnoBytes = uint8ArrayFromString(seqno.toString(16).padStart(16, '0'), 'base16')
|
22
22
|
|
23
23
|
const msgId = new Uint8Array(key.length + seqnoBytes.length)
|
@@ -30,7 +30,7 @@ export const msgId = (key: Uint8Array, seqno: bigint) => {
|
|
30
30
|
/**
|
31
31
|
* Generate a message id, based on message `data`
|
32
32
|
*/
|
33
|
-
export const noSignMsgId = (data: Uint8Array) => {
|
33
|
+
export const noSignMsgId = (data: Uint8Array): Uint8Array | Promise<Uint8Array> => {
|
34
34
|
return sha256.encode(data)
|
35
35
|
}
|
36
36
|
|
@@ -38,7 +38,7 @@ export const noSignMsgId = (data: Uint8Array) => {
|
|
38
38
|
* Check if any member of the first set is also a member
|
39
39
|
* of the second set
|
40
40
|
*/
|
41
|
-
export const anyMatch = (a: Set<number> | number[], b: Set<number> | number[]) => {
|
41
|
+
export const anyMatch = (a: Set<number> | number[], b: Set<number> | number[]): boolean => {
|
42
42
|
let bHas
|
43
43
|
if (Array.isArray(b)) {
|
44
44
|
bHas = (val: number) => b.includes(val)
|
@@ -58,7 +58,7 @@ export const anyMatch = (a: Set<number> | number[], b: Set<number> | number[]) =
|
|
58
58
|
/**
|
59
59
|
* Make everything an array
|
60
60
|
*/
|
61
|
-
export const ensureArray = function <T> (maybeArray: T | T[]) {
|
61
|
+
export const ensureArray = function <T> (maybeArray: T | T[]): T[] {
|
62
62
|
if (!Array.isArray(maybeArray)) {
|
63
63
|
return [maybeArray]
|
64
64
|
}
|