@tabcat/orbit-db-fsstore
Advanced tools
Comparing version 2.0.0 to 3.0.0
{ | ||
"name": "@tabcat/orbit-db-fsstore", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "a custom orbit-db store representing a file system", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -39,7 +39,13 @@ | ||
function joinPath (path, ...names) { | ||
if (!names.every(nameValid)) throw new Error('invalid name supplied') | ||
return `${path}/${names.join('/')}` | ||
function joinPath (path, name) { | ||
if (!pathValid(path)) throw errors.pathValidNo(path) | ||
if (!nameValid(name)) throw errors.nameValidNo(name) | ||
return `${path}/${name}` | ||
} | ||
function pathName (path) { | ||
if (!pathValid(path)) throw errors.pathValidNo(path) | ||
return path.split('/')[path.split('/').length - 1] | ||
} | ||
function tree (fs, path) { | ||
@@ -170,2 +176,9 @@ const a = [] | ||
const errors = { | ||
pathValidNo: (path) => new Error(`path ${path} is not valid`), | ||
nameValidNo: (name) => new Error(`name ${name} is not valid`), | ||
pathExistNo: (path) => new Error(`path '${path}' does not exist`), | ||
pathExistYes: (path) => new Error(`path '${path}' already exists`) | ||
} | ||
const ops = { | ||
@@ -185,2 +198,3 @@ mkdir, | ||
module.exports = { | ||
errors, | ||
ops, | ||
@@ -198,3 +212,4 @@ create, | ||
nameValid, | ||
joinPath | ||
joinPath, | ||
pathName | ||
} |
@@ -6,11 +6,5 @@ | ||
const FSIndex = require('./FSIndex') | ||
const { joinPath, pathValid, nameValid, opcodes, ...fs } = require('./FS') | ||
const FS = require('./FS') | ||
const { joinPath, pathName, pathValid, nameValid, opcodes, errors, ...fs } = FS | ||
const errors = { | ||
pathValidNo: (path) => new Error(`path ${path} is not valid`), | ||
nameValidNo: (name) => new Error(`name ${name} is not valid`), | ||
pathExistNo: (path) => new Error(`path '${path}' does not exist`), | ||
pathExistYes: (path) => new Error(`path '${path}' already exists`) | ||
} | ||
const paramCheckKeys = { | ||
@@ -70,2 +64,3 @@ path: 'path', | ||
this.joinPath = joinPath | ||
this.pathName = pathName | ||
this.exists = (path = '') => fs.exists(this._index.get(), path) | ||
@@ -142,2 +137,5 @@ this.content = (path = '') => fs.content(this._index.get(), path) | ||
FSStore.prototype.FS = FS | ||
FSStore.prototype.FSIndex = FSIndex | ||
module.exports = FSStore |
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
15526
327