(stream)
| 74 | } |
| 75 | |
| 76 | static streamReader(stream) { |
| 77 | const reader = new StreamReader(stream) |
| 78 | return async function read() { |
| 79 | try { |
| 80 | let length = await reader.read(4) |
| 81 | if (length == null) return true |
| 82 | length = parseInt(length.toString('utf8'), 16) |
| 83 | if (length === 0) return null |
| 84 | if (length === 1) return null // delim packets |
| 85 | const buffer = await reader.read(length - 4) |
| 86 | if (buffer == null) return true |
| 87 | return buffer |
| 88 | } catch (err) { |
| 89 | stream.error = err |
| 90 | return true |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | } |
no test coverage detected