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

Commit

Permalink
deps: update deps to support no-copy operations (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Aug 3, 2022
1 parent 1927144 commit 7be8515
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
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())
}
}

0 comments on commit 7be8515

Please sign in to comment.