| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 81f3eb5 commit 82eeadb
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -72,6 +72,7 @@ const { | |||
| 72 | 72 | stringToFlags, | |
| 73 | 73 | stringToSymlinkType, | |
| 74 | 74 | toUnixTimestamp, | |
| 75 | + validateBufferArray, | ||
| 75 | 76 | validateOffsetLengthRead, | |
| 76 | 77 | validateOffsetLengthWrite, | |
| 77 | 78 | validatePath, | |
@@ -142,19 +143,6 @@ function maybeCallback(cb) { | |||
| 142 | 143 | throw new ERR_INVALID_CALLBACK(cb); | |
| 143 | 144 | } | |
| 144 | 145 | ||
| 145 | - function isBuffersArray(value) { | ||
| 146 | - if (!Array.isArray(value)) | ||
| 147 | - return false; | ||
| 148 | - | ||
| 149 | - for (var i = 0; i < value.length; i += 1) { | ||
| 150 | - if (!isArrayBufferView(value[i])) { | ||
| 151 | - return false; | ||
| 152 | - } | ||
| 153 | - } | ||
| 154 | - | ||
| 155 | - return true; | ||
| 156 | - } | ||
| 157 | - | ||
| 158 | 146 | // Ensure that callbacks run in the global context. Only use this function | |
| 159 | 147 | // for callbacks that are passed to the binding layer, callbacks that are | |
| 160 | 148 | // invoked from JS already run in the proper scope. | |
@@ -610,10 +598,7 @@ function writev(fd, buffers, position, callback) { | |||
| 610 | 598 | } | |
| 611 | 599 | ||
| 612 | 600 | validateInt32(fd, 'fd', 0); | |
| 613 | - | ||
| 614 | - if (!isBuffersArray(buffers)) { | ||
| 615 | - throw new ERR_INVALID_ARG_TYPE('buffers', 'ArrayBufferView[]', buffers); | ||
| 616 | - } | ||
| 601 | + validateBufferArray(buffers); | ||
| 617 | 602 | ||
| 618 | 603 | const req = new FSReqCallback(); | |
| 619 | 604 | req.oncomplete = wrapper; | |
@@ -631,15 +616,11 @@ Object.defineProperty(writev, internalUtil.customPromisifyArgs, { | |||
| 631 | 616 | enumerable: false | |
| 632 | 617 | }); | |
| 633 | 618 | ||
| 634 | - // fs.writevSync(fd, buffers[, position]); | ||
| 635 | 619 | function writevSync(fd, buffers, position) { | |
| 636 | - | ||
| 637 | 620 | validateInt32(fd, 'fd', 0); | |
| 638 | - const ctx = {}; | ||
| 621 | + validateBufferArray(buffers); | ||
| 639 | 622 | ||
| 640 | - if (!isBuffersArray(buffers)) { | ||
| 641 | - throw new ERR_INVALID_ARG_TYPE('buffers', 'ArrayBufferView[]', buffers); | ||
| 642 | - } | ||
| 623 | + const ctx = {}; | ||
| 643 | 624 | ||
| 644 | 625 | if (typeof position !== 'number') | |
| 645 | 626 | position = null; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments