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 摘要。