* Reads file from the specified `fd` (file descriptor) * and writes to an array of `ArrayBufferView`s. * @param {number} fd * @param {ArrayBufferView[]} buffers * @param {number | null} [position] * @param {( * err?: Error, * bytesRead?: number, * buffers?: ArrayBufferView[] * ) => an
(fd, buffers, position, callback)
| 910 | * @returns {void} |
| 911 | */ |
| 912 | function readv(fd, buffers, position, callback) { |
| 913 | function wrapper(err, read) { |
| 914 | callback(err, read || 0, buffers); |
| 915 | } |
| 916 | |
| 917 | fd = getValidatedFd(fd); |
| 918 | validateBufferArray(buffers); |
| 919 | callback ||= position; |
| 920 | validateFunction(callback, 'cb'); |
| 921 | |
| 922 | if (typeof position !== 'number') |
| 923 | position = null; |
| 924 | |
| 925 | const h = vfsState.handlers; |
| 926 | if (h !== null) { |
| 927 | const promise = h.readv(fd, buffers, position); |
| 928 | if (promise !== undefined) { |
| 929 | PromisePrototypeThen(promise, |
| 930 | (read) => callback(null, read, buffers), callback); |
| 931 | return; |
| 932 | } |
| 933 | } |
| 934 | |
| 935 | const req = new FSReqCallback(); |
| 936 | req.oncomplete = wrapper; |
| 937 | |
| 938 | binding.readBuffers(fd, buffers, position, req); |
| 939 | } |
| 940 | |
| 941 | ObjectDefineProperty(readv, kCustomPromisifyArgsSymbol, |
| 942 | { __proto__: null, value: ['bytesRead', 'buffers'], enumerable: false }); |
no test coverage detected
searching dependent graphs…