bare-fs 1.6.4 → 1.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +8 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -203,7 +203,7 @@ function read (fd, buffer, offset, len, pos, cb) {
|
|
|
203
203
|
throw typeError('ERR_OUT_OF_RANGE', 'File descriptor is out of range. It must be >= 0 && <= 2147483647. Received ' + fd)
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
206
|
+
if (!Buffer.isBuffer(buffer) && !ArrayBuffer.isView(buffer)) {
|
|
207
207
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Buffer must be a buffer. Received type ' + (typeof buffer) + ' (' + buffer + ')')
|
|
208
208
|
}
|
|
209
209
|
|
|
@@ -241,7 +241,7 @@ function readSync (fd, buffer, offset = 0, len = buffer.byteLength - offset, pos
|
|
|
241
241
|
throw typeError('ERR_OUT_OF_RANGE', 'File descriptor is out of range. It must be >= 0 && <= 2147483647. Received ' + fd)
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
244
|
+
if (!Buffer.isBuffer(buffer) && !ArrayBuffer.isView(buffer)) {
|
|
245
245
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Buffer must be a buffer. Received type ' + (typeof buffer) + ' (' + buffer + ')')
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -280,7 +280,7 @@ function write (fd, buffer, offset, len, pos, cb) {
|
|
|
280
280
|
throw typeError('ERR_OUT_OF_RANGE', 'File descriptor is out of range. It must be >= 0 && <= 2147483647. Received ' + fd)
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
283
|
+
if (!Buffer.isBuffer(buffer) && !ArrayBuffer.isView(buffer)) {
|
|
284
284
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Buffer must be a buffer. Received type ' + (typeof buffer) + ' (' + buffer + ')')
|
|
285
285
|
}
|
|
286
286
|
|
|
@@ -318,7 +318,7 @@ function writeSync (fd, buffer, offset = 0, len = buffer.byteLength - offset, po
|
|
|
318
318
|
throw typeError('ERR_OUT_OF_RANGE', 'File descriptor is out of range. It must be >= 0 && <= 2147483647. Received ' + fd)
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
321
|
+
if (!Buffer.isBuffer(buffer) && !ArrayBuffer.isView(buffer)) {
|
|
322
322
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Buffer must be a buffer. Received type ' + (typeof buffer) + ' (' + buffer + ')')
|
|
323
323
|
}
|
|
324
324
|
|
|
@@ -743,7 +743,7 @@ function writeFile (path, data, opts, cb) {
|
|
|
743
743
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')')
|
|
744
744
|
}
|
|
745
745
|
|
|
746
|
-
if (typeof data !== 'string' && !Buffer.isBuffer(data)) {
|
|
746
|
+
if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
|
|
747
747
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
|
|
748
748
|
}
|
|
749
749
|
|
|
@@ -759,12 +759,12 @@ function writeFile (path, data, opts, cb) {
|
|
|
759
759
|
|
|
760
760
|
if (typeof data === 'string') data = Buffer.from(data, opts.encoding)
|
|
761
761
|
|
|
762
|
-
open(path, opts.flag || 'w', opts.mode, function (err, fd) {
|
|
762
|
+
open(path, opts.flag || 'w', opts || 0o666.mode, function (err, fd) {
|
|
763
763
|
if (err) return cb(err)
|
|
764
764
|
|
|
765
765
|
write(fd, data, loop)
|
|
766
766
|
|
|
767
|
-
function loop (err, w
|
|
767
|
+
function loop (err, w) {
|
|
768
768
|
if (err) return closeAndError(err)
|
|
769
769
|
if (w === data.byteLength) return done()
|
|
770
770
|
write(fd, data.subarray(w), loop)
|
|
@@ -790,7 +790,7 @@ function writeFileSync (path, data, opts) {
|
|
|
790
790
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')')
|
|
791
791
|
}
|
|
792
792
|
|
|
793
|
-
if (typeof data !== 'string' && !Buffer.isBuffer(data)) {
|
|
793
|
+
if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
|
|
794
794
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
|
|
795
795
|
}
|
|
796
796
|
|