Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

deps: update deps to support no-copy operations #55

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@
"@libp2p/interface-dht": "^1.0.0",
"err-code": "^3.0.1",
"multiformats": "^9.4.5",
"protons-runtime": "^1.0.2",
"protons-runtime": "^2.0.2",
"uint8arraylist": "^2.1.1",
"uint8arrays": "^3.0.0"
},
"devDependencies": {
"@libp2p/crypto": "^0.22.10",
"@libp2p/crypto": "^1.0.2",
"aegir": "^37.0.13",
"protons": "^3.0.2"
"protons": "^4.0.1"
}
}
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Uint8ArrayList } from 'uint8arraylist'
import {
Record
} from './record.js'
Expand Down Expand Up @@ -40,7 +41,7 @@ export class Libp2pRecord {
/**
* Decode a protobuf encoded record
*/
static deserialize (raw: Uint8Array) {
static deserialize (raw: Uint8Array | Uint8ArrayList) {
const rec = Record.decode(raw)

return new Libp2pRecord(rec.key, rec.value, new Date(rec.timeReceived))
Expand Down
5 changes: 3 additions & 2 deletions src/record.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import { encodeMessage, decodeMessage, message, bytes, string } from 'protons-runtime'
import type { Codec } from 'protons-runtime'
import type { Uint8ArrayList } from 'uint8arraylist'

export interface Record {
key: Uint8Array
Expand All @@ -19,11 +20,11 @@ export namespace Record {
})
}

export const encode = (obj: Record): Uint8Array => {
export const encode = (obj: Record): Uint8ArrayList => {
return encodeMessage(obj, Record.codec())
}

export const decode = (buf: Uint8Array): Record => {
export const decode = (buf: Uint8Array | Uint8ArrayList): Record => {
return decodeMessage(buf, Record.codec())
}
}