bare-fs 2.1.5 → 2.2.0
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 +5 -1
- package/index.js +48 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ fs.watch
|
|
|
38
38
|
fs.write
|
|
39
39
|
fs.writev
|
|
40
40
|
|
|
41
|
+
fs.appendFile
|
|
41
42
|
fs.readFile
|
|
42
43
|
fs.writeFile
|
|
43
44
|
|
|
@@ -46,7 +47,6 @@ fs.promises.chmod
|
|
|
46
47
|
fs.promises.lstat
|
|
47
48
|
fs.promises.mkdir
|
|
48
49
|
fs.promises.opendir
|
|
49
|
-
fs.promises.readFile
|
|
50
50
|
fs.promises.readdir
|
|
51
51
|
fs.promises.readlink
|
|
52
52
|
fs.promises.realpath
|
|
@@ -56,6 +56,9 @@ fs.promises.stat
|
|
|
56
56
|
fs.promises.symlink
|
|
57
57
|
fs.promises.unlink
|
|
58
58
|
fs.promises.watch
|
|
59
|
+
|
|
60
|
+
fs.promises.appendFile
|
|
61
|
+
fs.promises.readFile
|
|
59
62
|
fs.promises.writeFile
|
|
60
63
|
|
|
61
64
|
fs.createReadStream
|
|
@@ -82,6 +85,7 @@ fs.symlinkSync
|
|
|
82
85
|
fs.unlinkSync
|
|
83
86
|
fs.writeSync
|
|
84
87
|
|
|
88
|
+
fs.appendFileSync
|
|
85
89
|
fs.readFileSync
|
|
86
90
|
fs.writeFileSync
|
|
87
91
|
```
|
package/index.js
CHANGED
|
@@ -1327,6 +1327,51 @@ function writeFileSync (filepath, data, opts) {
|
|
|
1327
1327
|
}
|
|
1328
1328
|
}
|
|
1329
1329
|
|
|
1330
|
+
function appendFile (filepath, data, opts, cb) {
|
|
1331
|
+
if (typeof filepath !== 'string') {
|
|
1332
|
+
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')')
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
|
|
1336
|
+
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
if (typeof opts === 'function') {
|
|
1340
|
+
cb = opts
|
|
1341
|
+
opts = {}
|
|
1342
|
+
} else if (typeof cb !== 'function') {
|
|
1343
|
+
throw typeError('ERR_INVALID_ARG_TYPE', 'Callback must be a function. Received type ' + (typeof cb) + ' (' + cb + ')')
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
if (typeof opts === 'string') opts = { encoding: opts }
|
|
1347
|
+
else if (!opts) opts = {}
|
|
1348
|
+
|
|
1349
|
+
opts = { ...opts }
|
|
1350
|
+
|
|
1351
|
+
if (!opts.flags) opts.flag = 'a'
|
|
1352
|
+
|
|
1353
|
+
return writeFile(filepath, data, opts, cb)
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
function appendFileSync (filepath, data, opts) {
|
|
1357
|
+
if (typeof filepath !== 'string') {
|
|
1358
|
+
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')')
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
|
|
1362
|
+
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
if (typeof opts === 'string') opts = { encoding: opts }
|
|
1366
|
+
else if (!opts) opts = {}
|
|
1367
|
+
|
|
1368
|
+
opts = { ...opts }
|
|
1369
|
+
|
|
1370
|
+
if (!opts.flags) opts.flag = 'a'
|
|
1371
|
+
|
|
1372
|
+
return writeFileSync(filepath, data, opts)
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1330
1375
|
function watch (filepath, opts, cb) {
|
|
1331
1376
|
if (typeof filepath !== 'string') {
|
|
1332
1377
|
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')')
|
|
@@ -1783,6 +1828,7 @@ function typeError (code, message) {
|
|
|
1783
1828
|
function noop () {}
|
|
1784
1829
|
|
|
1785
1830
|
exports.access = access
|
|
1831
|
+
exports.appendFile = appendFile
|
|
1786
1832
|
exports.chmod = chmod
|
|
1787
1833
|
exports.close = close
|
|
1788
1834
|
exports.exists = exists
|
|
@@ -1811,6 +1857,7 @@ exports.writeFile = writeFile
|
|
|
1811
1857
|
exports.writev = writev
|
|
1812
1858
|
|
|
1813
1859
|
exports.accessSync = accessSync
|
|
1860
|
+
exports.appendFileSync = appendFileSync
|
|
1814
1861
|
exports.chmodSync = chmodSync
|
|
1815
1862
|
exports.closeSync = closeSync
|
|
1816
1863
|
exports.existsSync = existsSync
|
|
@@ -1835,6 +1882,7 @@ exports.writeFileSync = writeFileSync
|
|
|
1835
1882
|
exports.writeSync = writeSync
|
|
1836
1883
|
|
|
1837
1884
|
exports.promises.access = promisify(access)
|
|
1885
|
+
exports.promises.appendFile = promisify(appendFile)
|
|
1838
1886
|
exports.promises.chmod = promisify(chmod)
|
|
1839
1887
|
exports.promises.lstat = promisify(lstat)
|
|
1840
1888
|
exports.promises.mkdir = promisify(mkdir)
|