Comparing version 1.13.3 to 2.0.0
@@ -1,1 +0,1 @@ | ||
module.exports = process.addon(__dirname) | ||
module.exports = require.addon() |
370
index.js
@@ -1,7 +0,9 @@ | ||
const EventEmitter = require('events') | ||
const { sep, resolve, isAbsolute, toNamespacedPath } = require('path') | ||
/* global Bare */ | ||
const EventEmitter = require('bare-events') | ||
const os = require('bare-os') | ||
const path = require('bare-path') | ||
const { Readable, Writable } = require('streamx') | ||
const binding = require('./binding') | ||
const isWindows = process.platform === 'win32' | ||
const isWindows = os.platform() === 'win32' | ||
@@ -62,3 +64,3 @@ const constants = exports.constants = { | ||
process.on('exit', () => binding.destroy(fs.handle)) | ||
Bare.on('exit', () => binding.destroy(fs.handle)) | ||
@@ -147,5 +149,5 @@ // Lightly-modified from the Node FS internal utils. | ||
function open (path, flags, mode, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function open (filepath, flags, mode, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -171,8 +173,8 @@ | ||
req.callback = cb | ||
binding.open(req.handle, path, flags, mode) | ||
binding.open(req.handle, filepath, flags, mode) | ||
} | ||
function openSync (path, flags = 'r', mode = 0o666) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function openSync (filepath, flags = 'r', mode = 0o666) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -183,3 +185,3 @@ | ||
return binding.openSync(path, flags, mode) | ||
return binding.openSync(filepath, flags, mode) | ||
} | ||
@@ -217,5 +219,5 @@ | ||
function access (path, mode, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function access (filepath, mode, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -234,11 +236,11 @@ | ||
req.callback = cb | ||
binding.access(req.handle, path, mode) | ||
binding.access(req.handle, filepath, mode) | ||
} | ||
function accessSync (path, mode = constants.F_OK) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function accessSync (filepath, mode = constants.F_OK) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
binding.accessSync(path, mode) | ||
binding.accessSync(filepath, mode) | ||
} | ||
@@ -400,5 +402,5 @@ | ||
function stat (path, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function stat (filepath, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -419,16 +421,16 @@ | ||
binding.stat(req.handle, path, data) | ||
binding.stat(req.handle, filepath, data) | ||
} | ||
function statSync (path) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function statSync (filepath) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
return new Stats(...binding.statSync(path)) | ||
return new Stats(...binding.statSync(filepath)) | ||
} | ||
function lstat (path, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function lstat (filepath, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -449,11 +451,11 @@ | ||
binding.lstat(req.handle, path, data) | ||
binding.lstat(req.handle, filepath, data) | ||
} | ||
function lstatSync (path) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function lstatSync (filepath) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
return new Stats(...binding.lstatSync(path)) | ||
return new Stats(...binding.lstatSync(filepath)) | ||
} | ||
@@ -519,5 +521,5 @@ | ||
function chmod (path, mode, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function chmod (filepath, mode, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -529,8 +531,8 @@ | ||
req.callback = cb | ||
binding.chmod(req.handle, path, mode) | ||
binding.chmod(req.handle, filepath, mode) | ||
} | ||
function chmodSync (path, mode) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function chmodSync (filepath, mode) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -540,3 +542,3 @@ | ||
binding.chmodSync(path, mode) | ||
binding.chmodSync(filepath, mode) | ||
} | ||
@@ -574,8 +576,8 @@ | ||
function mkdirRecursive (path, mode, cb) { | ||
mkdir(path, { mode }, function (err) { | ||
function mkdirRecursive (filepath, mode, cb) { | ||
mkdir(filepath, { mode }, function (err) { | ||
if (err === null) return cb(null, 0, null) | ||
if (err.code !== 'ENOENT') { | ||
stat(path, function (e, st) { | ||
stat(filepath, function (e, st) { | ||
if (e) return cb(e, e.errno, null) | ||
@@ -588,9 +590,9 @@ if (st.isDirectory()) return cb(null, 0, null) | ||
while (path.endsWith(sep)) path = path.slice(0, -1) | ||
const i = path.lastIndexOf(sep) | ||
while (filepath.endsWith(path.sep)) filepath = filepath.slice(0, -1) | ||
const i = filepath.lastIndexOf(path.sep) | ||
if (i <= 0) return cb(err, err.errno, null) | ||
mkdirRecursive(path.slice(0, i), mode, function (err) { | ||
mkdirRecursive(filepath.slice(0, i), mode, function (err) { | ||
if (err) return cb(err, err.errno, null) | ||
mkdir(path, { mode }, cb) | ||
mkdir(filepath, { mode }, cb) | ||
}) | ||
@@ -600,5 +602,5 @@ }) | ||
function mkdir (path, opts, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function mkdir (filepath, opts, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -618,29 +620,29 @@ | ||
if (opts.recursive) return mkdirRecursive(path, mode, cb) | ||
if (opts.recursive) return mkdirRecursive(filepath, mode, cb) | ||
const req = getReq() | ||
req.callback = cb | ||
binding.mkdir(req.handle, path, mode) | ||
binding.mkdir(req.handle, filepath, mode) | ||
} | ||
function mkdirResursiveSync (path, mode) { | ||
function mkdirResursiveSync (filepath, mode) { | ||
try { | ||
mkdirSync(path, { mode }) | ||
mkdirSync(filepath, { mode }) | ||
} catch (err) { | ||
if (err.code !== 'ENOENT' && statSync(path).isDirectory()) { | ||
if (err.code !== 'ENOENT' && statSync(filepath).isDirectory()) { | ||
return | ||
} | ||
while (path.endsWith(sep)) path = path.slice(0, -1) | ||
const i = path.lastIndexOf(sep) | ||
while (filepath.endsWith(path.sep)) filepath = filepath.slice(0, -1) | ||
const i = filepath.lastIndexOf(path.sep) | ||
if (i <= 0) throw err | ||
mkdirResursiveSync(path.slice(0, i), { mode }) | ||
mkdirSync(path, { mode }) | ||
mkdirResursiveSync(filepath.slice(0, i), { mode }) | ||
mkdirSync(filepath, { mode }) | ||
} | ||
} | ||
function mkdirSync (path, opts) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function mkdirSync (filepath, opts) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -653,10 +655,10 @@ | ||
if (opts.recursive) return mkdirResursiveSync(path, mode) | ||
if (opts.recursive) return mkdirResursiveSync(filepath, mode) | ||
binding.mkdirSync(path, mode) | ||
binding.mkdirSync(filepath, mode) | ||
} | ||
function rmdir (path, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function rmdir (filepath, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -670,15 +672,15 @@ | ||
req.callback = cb | ||
binding.rmdir(req.handle, path) | ||
binding.rmdir(req.handle, filepath) | ||
} | ||
function rmdirSync (path) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function rmdirSync (filepath) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
binding.rmdirSync(path) | ||
binding.rmdirSync(filepath) | ||
} | ||
function rmRecursive (path, opts, cb) { | ||
rmdir(path, function (err) { | ||
function rmRecursive (filepath, opts, cb) { | ||
rmdir(filepath, function (err) { | ||
if (err === null) return cb(null) | ||
@@ -688,6 +690,6 @@ | ||
readdir(path, function (err, files) { | ||
readdir(filepath, function (err, files) { | ||
if (err) return cb(err) | ||
if (files.length === 0) return rmdir(path, cb) | ||
if (files.length === 0) return rmdir(filepath, cb) | ||
@@ -698,3 +700,3 @@ let missing = files.length | ||
for (const file of files) { | ||
rm(path + sep + file, opts, function (err) { | ||
rm(filepath + path.sep + file, opts, function (err) { | ||
if (done) return | ||
@@ -707,3 +709,3 @@ | ||
if (--missing === 0) rmdir(path, cb) | ||
if (--missing === 0) rmdir(filepath, cb) | ||
}) | ||
@@ -715,5 +717,5 @@ } | ||
function rm (path, opts, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function rm (filepath, opts, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -730,3 +732,3 @@ | ||
lstat(path, function (err, st) { | ||
lstat(filepath, function (err, st) { | ||
if (err) { | ||
@@ -737,3 +739,3 @@ return cb(err.code === 'ENOENT' && opts.force ? null : err) | ||
if (st.isDirectory()) { | ||
if (opts.recursive) return rmRecursive(path, opts, cb) | ||
if (opts.recursive) return rmRecursive(filepath, opts, cb) | ||
@@ -745,25 +747,25 @@ const err = new Error('is a directory') | ||
unlink(path, cb) | ||
unlink(filepath, cb) | ||
}) | ||
} | ||
function rmRecursiveSync (path, opts) { | ||
function rmRecursiveSync (filepath, opts) { | ||
try { | ||
rmdirSync(path) | ||
rmdirSync(filepath) | ||
} catch (err) { | ||
if (err.code !== 'ENOTEMPTY') throw err | ||
const files = readdirSync(path) | ||
const files = readdirSync(filepath) | ||
for (const file of files) { | ||
rmSync(path + sep + file, opts) | ||
rmSync(filepath + path.sep + file, opts) | ||
} | ||
rmdirSync(path) | ||
rmdirSync(filepath) | ||
} | ||
} | ||
function rmSync (path, opts) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function rmSync (filepath, opts) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -774,6 +776,6 @@ | ||
try { | ||
const st = lstatSync(path) | ||
const st = lstatSync(filepath) | ||
if (st.isDirectory()) { | ||
if (opts.recursive) return rmRecursiveSync(path, opts) | ||
if (opts.recursive) return rmRecursiveSync(filepath, opts) | ||
@@ -785,3 +787,3 @@ const err = new Error('is a directory') | ||
unlinkSync(path) | ||
unlinkSync(filepath) | ||
} catch (err) { | ||
@@ -792,5 +794,5 @@ if (err.code !== 'ENOENT' || !opts.force) throw err | ||
function unlink (path, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function unlink (filepath, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -804,11 +806,11 @@ | ||
req.callback = cb | ||
binding.unlink(req.handle, path) | ||
binding.unlink(req.handle, filepath) | ||
} | ||
function unlinkSync (path) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function unlinkSync (filepath) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
binding.unlinkSync(path) | ||
binding.unlinkSync(filepath) | ||
} | ||
@@ -846,5 +848,5 @@ | ||
function realpath (path, opts, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function realpath (filepath, opts, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -877,8 +879,8 @@ | ||
binding.realpath(req.handle, path, data) | ||
binding.realpath(req.handle, filepath, data) | ||
} | ||
function realpathSync (path, opts) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function realpathSync (filepath, opts) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -895,12 +897,12 @@ | ||
binding.realpathSync(path, data) | ||
binding.realpathSync(filepath, data) | ||
path = data.subarray(0, data.indexOf(0)) | ||
if (encoding !== 'buffer') path = path.toString(encoding) | ||
return path | ||
filepath = data.subarray(0, data.indexOf(0)) | ||
if (encoding !== 'buffer') filepath = filepath.toString(encoding) | ||
return filepath | ||
} | ||
function readlink (path, opts, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function readlink (filepath, opts, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -933,8 +935,8 @@ | ||
binding.readlink(req.handle, path, data) | ||
binding.readlink(req.handle, filepath, data) | ||
} | ||
function readlinkSync (path, opts) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function readlinkSync (filepath, opts) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -951,16 +953,16 @@ | ||
binding.readlinkSync(path, data) | ||
binding.readlinkSync(filepath, data) | ||
path = data.subarray(0, data.indexOf(0)) | ||
if (encoding !== 'buffer') path = path.toString(encoding) | ||
return path | ||
filepath = data.subarray(0, data.indexOf(0)) | ||
if (encoding !== 'buffer') filepath = filepath.toString(encoding) | ||
return filepath | ||
} | ||
function normalizeSymlinkTarget (target, type, path) { | ||
function normalizeSymlinkTarget (target, type, filepath) { | ||
if (isWindows) { | ||
if (type === 'junction') target = resolve(path, '..', target) | ||
if (type === 'junction') target = path.resolve(filepath, '..', target) | ||
if (isAbsolute(target)) return toNamespacedPath(target) | ||
if (path.isAbsolute(target)) return path.toNamespacedPath(target) | ||
return target.replace(/\//g, sep) | ||
return target.replace(/\//g, path.sep) | ||
} | ||
@@ -971,9 +973,9 @@ | ||
function symlink (target, path, type, cb) { | ||
function symlink (target, filepath, type, cb) { | ||
if (typeof target !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Target must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Target must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1004,3 +1006,3 @@ | ||
if (isWindows) { | ||
target = resolve(path, '..', target) | ||
target = path.resolve(filepath, '..', target) | ||
@@ -1010,3 +1012,3 @@ stat(target, (err, st) => { | ||
symlink(target, path, type, path, cb) | ||
symlink(target, filepath, type, filepath, cb) | ||
}) | ||
@@ -1022,12 +1024,12 @@ | ||
req.callback = cb | ||
binding.symlink(req.handle, normalizeSymlinkTarget(target), toNamespacedPath(path), type) | ||
binding.symlink(req.handle, normalizeSymlinkTarget(target), path.toNamespacedPath(filepath), type) | ||
} | ||
function symlinkSync (target, path, type) { | ||
function symlinkSync (target, filepath, type) { | ||
if (typeof target !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Target must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Target must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1051,3 +1053,3 @@ | ||
if (isWindows) { | ||
target = resolve(path, '..', target) | ||
target = path.resolve(filepath, '..', target) | ||
@@ -1060,8 +1062,8 @@ type = statSync(target).isDirectory() ? constants.UV_FS_SYMLINK_DIR : constants.UV_FS_SYMLINK_JUNCTION | ||
binding.symlinkSync(normalizeSymlinkTarget(target), toNamespacedPath(path), type) | ||
binding.symlinkSync(normalizeSymlinkTarget(target), path.toNamespacedPath(filepath), type) | ||
} | ||
function opendir (path, opts, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function opendir (filepath, opts, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1085,11 +1087,11 @@ | ||
if (err) return cb(err, null) | ||
cb(null, new Dir(path, data, opts)) | ||
cb(null, new Dir(filepath, data, opts)) | ||
} | ||
binding.opendir(req.handle, path, data) | ||
binding.opendir(req.handle, filepath, data) | ||
} | ||
function opendirSync (path, opts) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function opendirSync (filepath, opts) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1101,9 +1103,9 @@ | ||
const data = Buffer.allocUnsafe(binding.sizeofFSDir) | ||
binding.opendirSync(path, data) | ||
return new Dir(path, data, opts) | ||
binding.opendirSync(filepath, data) | ||
return new Dir(filepath, data, opts) | ||
} | ||
function readdir (path, opts, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function readdir (filepath, opts, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1125,3 +1127,3 @@ | ||
opendir(path, opts, async (err, dir) => { | ||
opendir(filepath, opts, async (err, dir) => { | ||
if (err) return cb(err, null) | ||
@@ -1136,5 +1138,5 @@ const result = [] | ||
function readdirSync (path, opts) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function readdirSync (filepath, opts) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1149,3 +1151,3 @@ | ||
const dir = opendirSync(path, opts) | ||
const dir = opendirSync(filepath, opts) | ||
const result = [] | ||
@@ -1162,5 +1164,5 @@ | ||
function readFile (path, opts, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function readFile (filepath, opts, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1182,3 +1184,3 @@ | ||
open(path, opts.flag || 'r', function (err, fd) { | ||
open(filepath, opts.flag || 'r', function (err, fd) { | ||
if (err) return cb(err) | ||
@@ -1219,5 +1221,5 @@ | ||
function readFileSync (path, opts) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function readFileSync (filepath, opts) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1232,3 +1234,3 @@ | ||
const fd = openSync(path, opts.flag || 'r') | ||
const fd = openSync(filepath, opts.flag || 'r') | ||
@@ -1257,5 +1259,5 @@ try { | ||
function writeFile (path, data, opts, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function writeFile (filepath, data, opts, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1279,3 +1281,3 @@ | ||
open(path, opts.flag || 'w', opts.mode || 0o666, function (err, fd) { | ||
open(filepath, opts.flag || 'w', opts.mode || 0o666, function (err, fd) { | ||
if (err) return cb(err) | ||
@@ -1306,5 +1308,5 @@ | ||
function writeFileSync (path, data, opts) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function writeFileSync (filepath, data, opts) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1321,3 +1323,3 @@ | ||
const fd = openSync(path, opts.flag || 'w', opts.mode) | ||
const fd = openSync(filepath, opts.flag || 'w', opts.mode) | ||
@@ -1338,5 +1340,5 @@ try { | ||
function watch (path, opts, cb) { | ||
if (typeof path !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof path) + ' (' + path + ')') | ||
function watch (filepath, opts, cb) { | ||
if (typeof filepath !== 'string') { | ||
throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')') | ||
} | ||
@@ -1352,3 +1354,3 @@ | ||
const watcher = new Watcher(path, opts) | ||
const watcher = new Watcher(filepath, opts) | ||
if (cb) watcher.on('change', cb) | ||
@@ -1355,0 +1357,0 @@ return watcher |
{ | ||
"name": "bare-fs", | ||
"version": "1.13.3", | ||
"version": "2.0.0", | ||
"description": "Native file system for Javascript", | ||
@@ -14,8 +14,11 @@ "main": "index.js", | ||
], | ||
"imports": { | ||
"events": "bare-events" | ||
}, | ||
"scripts": { | ||
"test": "standard && bare test.js" | ||
"test": "standard && bare -m package.json test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/holepunchto/bare-fs.git" | ||
"url": "git+https://github.com/holepunchto/bare-fs.git" | ||
}, | ||
@@ -29,2 +32,5 @@ "author": "Holepunch", | ||
"dependencies": { | ||
"bare-events": "^2.0.0", | ||
"bare-os": "^2.0.0", | ||
"bare-path": "^2.0.0", | ||
"streamx": "^2.13.0" | ||
@@ -31,0 +37,0 @@ }, |
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
118250
1450
4
+ Addedbare-events@^2.0.0
+ Addedbare-os@^2.0.0
+ Addedbare-path@^2.0.0
+ Addedbare-os@2.4.4(transitive)
+ Addedbare-path@2.1.3(transitive)