alanshaw / alanshaw/it-pipe

如何传输二进制数组

未關閉
#5 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
TypeScript
星號
43
分支
8
PR 合併指標
30 天內沒有已合併 PR

描述

I try to transfer a binary array, for example [85, 10, 17, 49, 49, 48, 55, 56, 57, 56, 53, 50, 64, 113, 113, 46, 99, 111, 109, 18] ,code show as below.

But listener.js did not receive the transmitted data

```js
// dialer.js
const { stream } = await dialerNode.dialProtocol(listenerMultiaddr, '/echo/1.0.0')

let data = [85, 10, 17, 49, 49, 48, 55, 56, 56, 57, 56, 53, 50, 64, 113, 113, 46, 99, 111, 109, 18, 64, 98, 99, 98, 49, 53, 102, 56, 50, 49, 52, 55, 57, 98, 52, 100, 53, 55, 55, 50, 98, 100, 48, 99, 97, 56, 54, 54, 99, 48, 48, 97, 100, 53, 102, 57, 50, 54, 101, 51, 53, 56, 48, 55, 50, 48, 54, 53, 57, 99, 99, 56, 48, 100, 51, 57, 99, 57, 100, 48, 57, 56, 48, 50, 97]
let result = await pipe(
data,
stream,
concat
)
console.log(result)

// listener.js
await listenerNode.handle('/echo/1.0.0', async ({ stream }) => {
let res = await pipe(
['test'],
stream,
async function collect (source) {
const vals = []
for await (const val of source) {
console.log('val', val)
vals.push(val)
}
return vals
}
)
console.log('res', res, res.toString())
})
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。