@peerbit/stream-interface
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -31,4 +31,4 @@ import { Uint8ArrayList } from "uint8arraylist"; | ||
export declare abstract class Message { | ||
static deserialize(bytes: Uint8ArrayList): DataMessage | Hello | Goodbye | PingPong; | ||
abstract serialize(): Uint8ArrayList | Uint8Array; | ||
static from(bytes: Uint8ArrayList): DataMessage | Hello | Goodbye | PingPong; | ||
abstract bytes(): Uint8ArrayList | Uint8Array; | ||
abstract equals(other: Message): boolean; | ||
@@ -64,4 +64,4 @@ abstract verify(expectSignatures: boolean): Promise<boolean>; | ||
/** Manually ser/der for performance gains */ | ||
serialize(): Uint8Array; | ||
static deserialize(bytes: Uint8ArrayList): DataMessage; | ||
bytes(): Uint8Array; | ||
static from(bytes: Uint8ArrayList): DataMessage; | ||
equals(other: Message): boolean; | ||
@@ -84,4 +84,4 @@ } | ||
get sender(): PublicSignKey; | ||
serialize(): Uint8Array; | ||
static deserialize(bytes: Uint8ArrayList): Hello; | ||
bytes(): Uint8Array; | ||
static from(bytes: Uint8ArrayList): Hello; | ||
_prefix: Uint8Array | undefined; | ||
@@ -106,4 +106,4 @@ get prefix(): Uint8Array; | ||
get sender(): PublicSignKey; | ||
serialize(): Uint8Array; | ||
static deserialize(bytes: Uint8ArrayList): Goodbye; | ||
bytes(): Uint8Array; | ||
static from(bytes: Uint8ArrayList): Goodbye; | ||
_prefix: Uint8Array | undefined; | ||
@@ -118,4 +118,4 @@ get prefix(): Uint8Array; | ||
export declare abstract class PingPong extends Message { | ||
static deserialize(bytes: Uint8ArrayList): PingPong; | ||
serialize(): Uint8ArrayList | Uint8Array; | ||
static from(bytes: Uint8ArrayList): PingPong; | ||
bytes(): Uint8ArrayList | Uint8Array; | ||
verify(_expectSignatures: boolean): Promise<boolean>; | ||
@@ -122,0 +122,0 @@ abstract get pingBytes(): Uint8Array; |
@@ -168,17 +168,17 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
export class Message { | ||
static deserialize(bytes) { | ||
static from(bytes) { | ||
if (bytes.get(0) === DATA_VARIANT) { | ||
// Data | ||
return DataMessage.deserialize(bytes); | ||
return DataMessage.from(bytes); | ||
} | ||
else if (bytes.get(0) === HELLO_VARIANT) { | ||
// heartbeat | ||
return Hello.deserialize(bytes); | ||
return Hello.from(bytes); | ||
} | ||
else if (bytes.get(0) === GOODBYE_VARIANT) { | ||
// heartbeat | ||
return Goodbye.deserialize(bytes); | ||
return Goodbye.from(bytes); | ||
} | ||
else if (bytes.get(0) === PING_VARIANT) { | ||
return PingPong.deserialize(bytes); | ||
return PingPong.from(bytes); | ||
} | ||
@@ -257,3 +257,3 @@ throw new Error("Unsupported"); | ||
/** Manually ser/der for performance gains */ | ||
serialize() { | ||
bytes() { | ||
if (this._serialized) { | ||
@@ -264,3 +264,3 @@ return this._serialized; | ||
} | ||
static deserialize(bytes) { | ||
static from(bytes) { | ||
if (bytes.get(0) !== 0) { | ||
@@ -346,6 +346,6 @@ throw new Error("Unsupported"); | ||
} | ||
serialize() { | ||
bytes() { | ||
return serialize(this); | ||
} | ||
static deserialize(bytes) { | ||
static from(bytes) { | ||
const result = deserialize(bytes.subarray(), Hello_1); | ||
@@ -446,6 +446,6 @@ if (result.signatures.signatures.length === 0) { | ||
} | ||
serialize() { | ||
bytes() { | ||
return serialize(this); | ||
} | ||
static deserialize(bytes) { | ||
static from(bytes) { | ||
const result = deserialize(bytes.subarray(), Goodbye_1); | ||
@@ -522,6 +522,6 @@ if (result.signatures.signatures.length === 0) { | ||
export let PingPong = PingPong_1 = class PingPong extends Message { | ||
static deserialize(bytes) { | ||
static from(bytes) { | ||
return deserialize(bytes.subarray(), PingPong_1); | ||
} | ||
serialize() { | ||
bytes() { | ||
return serialize(this); | ||
@@ -664,3 +664,3 @@ } | ||
} | ||
static deserialize(bytes: Uint8ArrayList): NetworkInfo { | ||
static from(bytes: Uint8ArrayList): NetworkInfo { | ||
return deserialize(bytes.subarray(), NetworkInfo) | ||
@@ -667,0 +667,0 @@ } |
{ | ||
"name": "@peerbit/stream-interface", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Block store streaming", | ||
@@ -54,5 +54,5 @@ "type": "module", | ||
"@libp2p/interface-peer-id": "^2.0.2", | ||
"@peerbit/crypto": "1.0.3" | ||
"@peerbit/crypto": "1.0.4" | ||
}, | ||
"gitHead": "99e30817f094e45ffcd60f4babd90a717bd26a22" | ||
"gitHead": "32f61ad9f3d5906e13d46f2a80f61c1826a3e817" | ||
} |
@@ -205,14 +205,14 @@ import { | ||
export abstract class Message { | ||
static deserialize(bytes: Uint8ArrayList) { | ||
static from(bytes: Uint8ArrayList) { | ||
if (bytes.get(0) === DATA_VARIANT) { | ||
// Data | ||
return DataMessage.deserialize(bytes); | ||
return DataMessage.from(bytes); | ||
} else if (bytes.get(0) === HELLO_VARIANT) { | ||
// heartbeat | ||
return Hello.deserialize(bytes); | ||
return Hello.from(bytes); | ||
} else if (bytes.get(0) === GOODBYE_VARIANT) { | ||
// heartbeat | ||
return Goodbye.deserialize(bytes); | ||
return Goodbye.from(bytes); | ||
} else if (bytes.get(0) === PING_VARIANT) { | ||
return PingPong.deserialize(bytes); | ||
return PingPong.from(bytes); | ||
} | ||
@@ -223,3 +223,3 @@ | ||
abstract serialize(): Uint8ArrayList | Uint8Array; | ||
abstract bytes(): Uint8ArrayList | Uint8Array; | ||
abstract equals(other: Message): boolean; | ||
@@ -336,3 +336,3 @@ abstract verify(expectSignatures: boolean): Promise<boolean>; | ||
/** Manually ser/der for performance gains */ | ||
serialize() { | ||
bytes() { | ||
if (this._serialized) { | ||
@@ -344,3 +344,3 @@ return this._serialized; | ||
static deserialize(bytes: Uint8ArrayList): DataMessage { | ||
static from(bytes: Uint8ArrayList): DataMessage { | ||
if (bytes.get(0) !== 0) { | ||
@@ -417,6 +417,6 @@ throw new Error("Unsupported"); | ||
serialize() { | ||
bytes() { | ||
return serialize(this); | ||
} | ||
static deserialize(bytes: Uint8ArrayList): Hello { | ||
static from(bytes: Uint8ArrayList): Hello { | ||
const result = deserialize(bytes.subarray(), Hello); | ||
@@ -530,6 +530,6 @@ if (result.signatures.signatures.length === 0) { | ||
serialize() { | ||
bytes() { | ||
return serialize(this); | ||
} | ||
static deserialize(bytes: Uint8ArrayList): Goodbye { | ||
static from(bytes: Uint8ArrayList): Goodbye { | ||
const result = deserialize(bytes.subarray(), Goodbye); | ||
@@ -611,7 +611,7 @@ if (result.signatures.signatures.length === 0) { | ||
export abstract class PingPong extends Message { | ||
static deserialize(bytes: Uint8ArrayList) { | ||
static from(bytes: Uint8ArrayList) { | ||
return deserialize(bytes.subarray(), PingPong); | ||
} | ||
serialize(): Uint8ArrayList | Uint8Array { | ||
bytes(): Uint8ArrayList | Uint8Array { | ||
return serialize(this); | ||
@@ -746,3 +746,3 @@ } | ||
} | ||
static deserialize(bytes: Uint8ArrayList): NetworkInfo { | ||
static from(bytes: Uint8ArrayList): NetworkInfo { | ||
return deserialize(bytes.subarray(), NetworkInfo) | ||
@@ -749,0 +749,0 @@ } |
Sorry, the diff of this file is not supported yet
75464
+ Added@peerbit/crypto@1.0.4(transitive)
- Removed@peerbit/crypto@1.0.3(transitive)
Updated@peerbit/crypto@1.0.4