Skip to content

Commit

Permalink
chore: release 0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Sloaix committed Aug 7, 2023
1 parent 357faf2 commit acf4faa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sloaix-node-bencode",
"version": "0.1.3",
"version": "0.1.4",
"description": "Bencode encoding and decoding, with both library and CLI versions available. The CLI version can decode bencode-formatted data from files or strings and output the result in JSON format.",
"keywords": [
"bencode",
Expand Down
6 changes: 5 additions & 1 deletion src/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ export class Bencoder {

// 字符串的编码格式为:字符串的长度 + ':' + 字符串
// 例如:4:spam
return this.encoder.encode(`${byteString.toString().length}:${byteString}`)
const buffers: Uint8Array[] = [this.encoder.encode(`${byteString.toString().length}:`)]

buffers.push(Buffer.from(byteString))

return Uint8Array.from(Buffer.concat(buffers))
}

/**
Expand Down

0 comments on commit acf4faa

Please sign in to comment.