bare-fs 4.7.0 → 4.7.1
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/README.md +2 -1
- package/index.js +39 -8
- package/package.json +1 -1
- package/prebuilds/android-arm/bare-fs.bare +0 -0
- package/prebuilds/android-arm64/bare-fs.bare +0 -0
- package/prebuilds/android-ia32/bare-fs.bare +0 -0
- package/prebuilds/android-x64/bare-fs.bare +0 -0
- package/prebuilds/darwin-arm64/bare-fs.bare +0 -0
- package/prebuilds/darwin-x64/bare-fs.bare +0 -0
- package/prebuilds/ios-arm64/bare-fs.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-fs.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-fs.bare +0 -0
- package/prebuilds/linux-arm64/bare-fs.bare +0 -0
- package/prebuilds/linux-x64/bare-fs.bare +0 -0
- package/prebuilds/win32-arm64/bare-fs.bare +0 -0
- package/prebuilds/win32-x64/bare-fs.bare +0 -0
package/README.md
CHANGED
package/index.js
CHANGED
|
@@ -286,6 +286,8 @@ async function read(fd, buffer, offset = 0, len = buffer.byteLength - offset, po
|
|
|
286
286
|
try {
|
|
287
287
|
binding.read(req.handle, fd, buffer, offset, len, pos)
|
|
288
288
|
|
|
289
|
+
req.retain(buffer)
|
|
290
|
+
|
|
289
291
|
bytes = await req
|
|
290
292
|
} catch (e) {
|
|
291
293
|
err = new FileError(e.message, { operation: 'read', code: e.code, fd })
|
|
@@ -323,6 +325,8 @@ async function readv(fd, buffers, pos = -1, cb) {
|
|
|
323
325
|
try {
|
|
324
326
|
binding.readv(req.handle, fd, buffers, pos)
|
|
325
327
|
|
|
328
|
+
req.retain(buffers)
|
|
329
|
+
|
|
326
330
|
bytes = await req
|
|
327
331
|
} catch (e) {
|
|
328
332
|
err = new FileError(e.message, { operation: 'readv', code: e.code, fd })
|
|
@@ -395,6 +399,8 @@ async function write(fd, data, offset, len, pos = -1, cb) {
|
|
|
395
399
|
try {
|
|
396
400
|
binding.write(req.handle, fd, data, offset, len, pos)
|
|
397
401
|
|
|
402
|
+
req.retain(data)
|
|
403
|
+
|
|
398
404
|
bytes = await req
|
|
399
405
|
} catch (e) {
|
|
400
406
|
err = new FileError(e.message, { operation: 'write', code: e.code, fd })
|
|
@@ -450,6 +456,8 @@ async function writev(fd, buffers, pos = -1, cb) {
|
|
|
450
456
|
try {
|
|
451
457
|
binding.writev(req.handle, fd, buffers, pos)
|
|
452
458
|
|
|
459
|
+
req.retain(buffers)
|
|
460
|
+
|
|
453
461
|
bytes = await req
|
|
454
462
|
} catch (e) {
|
|
455
463
|
err = new FileError(e.message, { operation: 'writev', code: e.code, fd })
|
|
@@ -1878,17 +1886,28 @@ async function readdir(filepath, opts, cb) {
|
|
|
1878
1886
|
if (typeof opts === 'string') opts = { encoding: opts }
|
|
1879
1887
|
else if (!opts) opts = {}
|
|
1880
1888
|
|
|
1881
|
-
const { withFileTypes = false } = opts
|
|
1889
|
+
const { withFileTypes = false, recursive = false } = opts
|
|
1882
1890
|
|
|
1883
1891
|
filepath = toNamespacedPath(filepath)
|
|
1884
1892
|
|
|
1893
|
+
const queue = [filepath]
|
|
1885
1894
|
let result = []
|
|
1886
1895
|
let err = null
|
|
1887
1896
|
try {
|
|
1888
|
-
|
|
1897
|
+
while (queue.length !== 0) {
|
|
1898
|
+
const dir = await opendir(queue.pop())
|
|
1899
|
+
|
|
1900
|
+
for await (const entry of dir) {
|
|
1901
|
+
const entryPath = path.join(entry.parentPath, entry.name)
|
|
1902
|
+
|
|
1903
|
+
if (withFileTypes) {
|
|
1904
|
+
result.push(entry)
|
|
1905
|
+
} else {
|
|
1906
|
+
result.push(path.relative(filepath, entryPath))
|
|
1907
|
+
}
|
|
1889
1908
|
|
|
1890
|
-
|
|
1891
|
-
|
|
1909
|
+
if (recursive && entry.isDirectory()) queue.push(entryPath)
|
|
1910
|
+
}
|
|
1892
1911
|
}
|
|
1893
1912
|
} catch (e) {
|
|
1894
1913
|
result = []
|
|
@@ -1902,15 +1921,27 @@ function readdirSync(filepath, opts) {
|
|
|
1902
1921
|
if (typeof opts === 'string') opts = { encoding: opts }
|
|
1903
1922
|
else if (!opts) opts = {}
|
|
1904
1923
|
|
|
1905
|
-
const { withFileTypes = false } = opts
|
|
1924
|
+
const { withFileTypes = false, recursive = false } = opts
|
|
1906
1925
|
|
|
1907
1926
|
filepath = toNamespacedPath(filepath)
|
|
1908
1927
|
|
|
1909
|
-
const
|
|
1928
|
+
const queue = [filepath]
|
|
1910
1929
|
const result = []
|
|
1911
1930
|
|
|
1912
|
-
|
|
1913
|
-
|
|
1931
|
+
while (queue.length !== 0) {
|
|
1932
|
+
const dir = opendirSync(queue.pop(), opts)
|
|
1933
|
+
|
|
1934
|
+
for (const entry of dir) {
|
|
1935
|
+
const entryPath = path.join(entry.parentPath, entry.name)
|
|
1936
|
+
|
|
1937
|
+
if (withFileTypes) {
|
|
1938
|
+
result.push(entry)
|
|
1939
|
+
} else {
|
|
1940
|
+
result.push(path.relative(filepath, entryPath))
|
|
1941
|
+
}
|
|
1942
|
+
|
|
1943
|
+
if (recursive && entry.isDirectory()) queue.push(entryPath)
|
|
1944
|
+
}
|
|
1914
1945
|
}
|
|
1915
1946
|
|
|
1916
1947
|
return result
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|