(config?: ExecOpts)
| 199 | ]) |
| 200 | |
| 201 | const execute = (config?: ExecOpts): Uint8Array => { |
| 202 | // this is the happy path for most queries |
| 203 | if (!config || (!config.portal && !config.rows)) { |
| 204 | return emptyExecute |
| 205 | } |
| 206 | |
| 207 | const portal = config.portal ?? '' |
| 208 | const rows = config.rows ?? 0 |
| 209 | |
| 210 | const portalLength = byteLengthUtf8(portal) |
| 211 | const len = 4 + portalLength + 1 + 4 |
| 212 | // one extra bit for code |
| 213 | const bufferView = new DataView(new ArrayBuffer(1 + len)) |
| 214 | bufferView.setUint8(0, code.execute) |
| 215 | bufferView.setInt32(1, len, false) |
| 216 | new TextEncoder().encodeInto(portal, new Uint8Array(bufferView.buffer, 5)) |
| 217 | bufferView.setUint8(portalLength + 5, 0) // null terminate portal cString |
| 218 | bufferView.setUint32(bufferView.byteLength - 4, rows, false) |
| 219 | return new Uint8Array(bufferView.buffer) |
| 220 | } |
| 221 | |
| 222 | const cancel = (processID: number, secretKey: number): Uint8Array => { |
| 223 | const bufferView = new DataView(new ArrayBuffer(16)) |
nothing calls this directly
no test coverage detected