(filehandle, data, signal, encoding)
| 1127 | } |
| 1128 | |
| 1129 | async function writeFileHandle(filehandle, data, signal, encoding) { |
| 1130 | checkAborted(signal); |
| 1131 | if (isCustomIterable(data)) { |
| 1132 | for await (const buf of data) { |
| 1133 | checkAborted(signal); |
| 1134 | const toWrite = |
| 1135 | isArrayBufferView(buf) ? buf : Buffer.from(buf, encoding || 'utf8'); |
| 1136 | let remaining = toWrite.byteLength; |
| 1137 | while (remaining > 0) { |
| 1138 | const writeSize = MathMin(kWriteFileMaxChunkSize, remaining); |
| 1139 | const { bytesWritten } = await write( |
| 1140 | filehandle, toWrite, toWrite.byteLength - remaining, writeSize); |
| 1141 | remaining -= bytesWritten; |
| 1142 | checkAborted(signal); |
| 1143 | } |
| 1144 | } |
| 1145 | return; |
| 1146 | } |
| 1147 | data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength); |
| 1148 | let remaining = data.byteLength; |
| 1149 | if (remaining === 0) return; |
| 1150 | do { |
| 1151 | checkAborted(signal); |
| 1152 | const { bytesWritten } = |
| 1153 | await write(filehandle, data, 0, |
| 1154 | MathMin(kWriteFileMaxChunkSize, data.byteLength)); |
| 1155 | remaining -= bytesWritten; |
| 1156 | data = new Uint8Array( |
| 1157 | data.buffer, |
| 1158 | data.byteOffset + bytesWritten, |
| 1159 | data.byteLength - bytesWritten, |
| 1160 | ); |
| 1161 | } while (remaining > 0); |
| 1162 | } |
| 1163 | |
| 1164 | async function readFileHandleWithUserBuffer(filehandle, options, size) { |
| 1165 | const signal = options?.signal; |
no test coverage detected
searching dependent graphs…