Comparing version 2.1.5 to 2.2.0
48
index.js
@@ -1330,2 +1330,47 @@ /* global Bare */ | ||
function appendFile (filepath, data, opts, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')') | ||
} | ||
if (typeof opts === 'function') { | ||
cb = opts | ||
opts = {} | ||
} else if (typeof cb !== 'function') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Callback must be a function. Received type ' + (typeof cb) + ' (' + cb + ')') | ||
} | ||
if (typeof opts === 'string') opts = { encoding: opts } | ||
else if (!opts) opts = {} | ||
opts = { ...opts } | ||
if (!opts.flags) opts.flag = 'a' | ||
return writeFile(filepath, data, opts, cb) | ||
} | ||
function appendFileSync (filepath, data, opts) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')') | ||
} | ||
if (typeof opts === 'string') opts = { encoding: opts } | ||
else if (!opts) opts = {} | ||
opts = { ...opts } | ||
if (!opts.flags) opts.flag = 'a' | ||
return writeFileSync(filepath, data, opts) | ||
} | ||
function watch (filepath, opts, cb) { | ||
@@ -1787,2 +1832,3 @@ if (typeof filepath !== 'string') { | ||
exports.access = access | ||
exports.appendFile = appendFile | ||
exports.chmod = chmod | ||
@@ -1816,2 +1862,3 @@ exports.close = close | ||
exports.accessSync = accessSync | ||
exports.appendFileSync = appendFileSync | ||
exports.chmodSync = chmodSync | ||
@@ -1841,2 +1888,3 @@ exports.closeSync = closeSync | ||
exports.promises.access = promisify(access) | ||
exports.promises.appendFile = promisify(appendFile) | ||
exports.promises.chmod = promisify(chmod) | ||
@@ -1843,0 +1891,0 @@ exports.promises.lstat = promisify(lstat) |
{ | ||
"name": "bare-fs", | ||
"version": "2.1.5", | ||
"version": "2.2.0", | ||
"description": "Native file system for Javascript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -41,2 +41,3 @@ # bare-fs | ||
fs.appendFile | ||
fs.readFile | ||
@@ -50,3 +51,2 @@ fs.writeFile | ||
fs.promises.opendir | ||
fs.promises.readFile | ||
fs.promises.readdir | ||
@@ -61,2 +61,5 @@ fs.promises.readlink | ||
fs.promises.watch | ||
fs.promises.appendFile | ||
fs.promises.readFile | ||
fs.promises.writeFile | ||
@@ -88,2 +91,3 @@ | ||
fs.appendFileSync | ||
fs.readFileSync | ||
@@ -90,0 +94,0 @@ fs.writeFileSync |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
414716
1521
96