New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@vorlefan/path

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vorlefan/path - npm Package Compare versions

Comparing version 1.5.6 to 1.5.61

2

dist/index.js

@@ -1,1 +0,1 @@

module.exports=function(e){var t={};function r(i){if(t[i])return t[i].exports;var s=t[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(i,s,function(t){return e[t]}.bind(null,s));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){e.exports=require("path")},function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Routes=t.Route=void 0;const s=i(r(2)),n={_routes:[],route:{},instance:Function,save:Function,load:Function};t.Routes=n;const a={};t.Route=a,n.instance=function(e,t){const r=new s.default;return r._namespace=t,e({instance:r}),n._routes.push(r),n.route[t]=r,a[t]=r,r},n.save=function({instance:e,routeName:t,filename:r,force:i=!0}){if(!(e&&e instanceof s.default))return!1;const n=e.routes();return e.json().set(t).storeSync({filename:r,data:n,force:i}),!0},n.load=function(e){const t=new s.default;let r=t.io().readSync({filename:"",folder:e});return r&&(r=JSON.parse(r),r.map(e=>t.set(e.name,e.path))),n._routes.push(t),t}},function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(r(0)),n=r(3);t.default=class{constructor(){this._routes=[],this._prefix="",this._namespace="",this._storage={},this._io=new n.FileManager(this),this._json=new n.FileJSON(this,"")}io(){return this._io}json(){return this._json}hasItem(e){return!!this._storage.hasOwnProperty(e)}setItem(e,t,r){return this.hasItem(e)&&r||(this._storage[e]=t),this._storage[e]}getItem(e){return this._storage[e]}routes(){return this._routes}has(e){return!!this._routes.find(t=>t.name===e)}remove(e){this.has(e)&&(this._routes=this._routes.filter(({name:t})=>t!==e))}set(e,t){if(this.has(e))return this.get(e);{const r={name:e,filepath:t};return this._routes.push(r),r}}get(e){const t={name:"",filepath:"",prefix:""},r=this._routes.find(({name:t})=>t===e);return r?Object.assign(t,r):t}alias(e,t){return this.has(t)&&this.set(e,this.get(t).filepath),this}join(e,t,r){if(this.has(t)){const i=this.get(t),n={name:e,filepath:s.default.join(i.filepath,r||e)};return this._routes.push(n),n}}inject(e,t,r){return this.io().hasFolder(t,r||e)||this.io().setFolder(e,r||t),this.join(e,t,r),this}prefix(e){return this._prefix=e,this._routes.forEach(t=>{t.hasOwnProperty("prefix")?t.name.replace(t.prefix||"",e):(t.name=`${e}/${t.name}`,t.prefix=e)}),this}plug(e,t){return s.default.join(this.get(e).filepath||"",t)}clean(e){return this.get(e).filepath.replace(/(\/)[(/)]/g,"/")}back(e,t=1){if(this.has(e)){const r=new Array(t).fill("..");return s.default.resolve(this.get(e).filepath,...r)}return""}endWith(e){const t=e.replace(/(\/)[(/)]/g,"/");return s.default.basename(t)}resolve(...e){return s.default.resolve(...e)}basename(e,t){return s.default.basename(e,t)}dirname(e){return s.default.dirname(e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(4);Object.defineProperty(t,"FileManager",{enumerable:!0,get:function(){return i.default}});var s=r(6);Object.defineProperty(t,"FileJSON",{enumerable:!0,get:function(){return s.default}})},function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(r(5)),n=i(r(0));t.default=class{constructor(e){return this._route=e,this._routeName="",this._historic=[],this}setRoute(e){return this._routeName=e,this}historic(){return this._historic}setHistoric(e,t,r){const i={routeName:e,filename:t,field:r};return this._historic.push(i),this}async accessFile(e,t=["R_OK","F_OK"]){const r=t.map(e=>s.default.constants[e]).reduce((e,t)=>t|e);return!!new Promise(t=>s.default.access(e,r,e=>t(!e)))}async copy(e,t){return!!await this.accessFile(t)&&(await s.default.promises.copyFile(t,this._route.plug(e,n.default.basename(t))),!0)}readSync({routeName:e=this._routeName,filename:t,folder:r}){if(!this._route.has(e)&&!r)return;const i="string"==typeof r?n.default.join(r,t):this._route.plug(e,t);if(!s.default.existsSync(i))return;this.setHistoric(e,t,"read");return s.default.readFileSync(i,"utf-8")}async read({routeName:e=this._routeName,filename:t,folder:r}){if(!this._route.has(e)&&!r)return;const i="string"==typeof r?n.default.join(r,t):this._route.plug(e,t);if(await this.accessFile(i)){this.setHistoric(e,i,"read");return await s.default.promises.readFile(i,"utf-8")}}storeSync({routeName:e=this._routeName,filename:t,force:r=!0,data:i}){if(!this._route.has(e))return!1;const n=this._route.plug(e,t);return s.default.existsSync(n)&&!r||(s.default.writeFileSync(n,i,"utf-8"),this.setHistoric(e,n,"write")),!0}async store({routeName:e=this._routeName,filename:t,force:r=!0,data:i}){if(!this._route.has(e))return!1;const n=this._route.plug(e,t);return await this.accessFile(n)&&!r||(await s.default.promises.writeFile(n,i,"utf-8"),this.setHistoric(e,t,"write")),!0}removeSync({routeName:e=this._routeName,filename:t}){if(!this._route.has(e))return!1;const r=this._route.plug(e,t);return!s.default.existsSync(r)||(s.default.unlinkSync(r),this.setHistoric(e,t,"remove"),!0)}async remove({routeName:e=this._routeName,filename:t}){if(!this._route.has(e))return!1;const r=this._route.plug(e,t);return!await this.accessFile(r)||(s.default.promises.unlink(r),this.setHistoric(e,t,"remove"),!0)}files({routeName:e=this._routeName,extension:t,options:r}){if(!this._route.has(e))return[];const i=this._route.get(e),a=i.filepath;if(!s.default.existsSync(a))return[];t&&"string"==typeof t&&(t=new RegExp(`.(${t})$`,"gi"));const o=[];return s.default.readdirSync(a,r).map(e=>{const r=n.default.join(a,e);if(!s.default.lstatSync(a).isDirectory()){let e=r.replace(/^.*[\\\/]/,""),s=n.default.extname(e);if(t&&!e.match(t))return;o.push({name:e.replace(s,""),filename:e,filepath:r,extension:s,routeName:i.name})}}),o}folders(e=this._routeName){if(!this._route.has(e))return[];const t=this._route.get(e);let r=s.default.readdirSync(t.filepath);r=r.map(e=>n.default.join(t.filepath,e)).filter(e=>s.default.lstatSync(e).isDirectory());const i=[];return r.map(e=>{const t=e.replace(/^.*[\\\/]/,"");i.push({name:t,path:e})}),i}hasFolder(e,t){if(!this._route.has(e))return!1;const r=n.default.join(this._route.get(e).filepath,t);return!!s.default.existsSync(r)&&s.default.lstatSync(r).isDirectory()}setFolder(e,t){const r=n.default.join(this._route.get(e).filepath,t);return this.hasFolder(e,t)||s.default.mkdirSync(r,{recursive:!1}),this}}},function(e,t){e.exports=require("fs")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e,t){return this._route=e,this._routeName=t,this}set(e){return this._routeName=e,this}readSync({routeName:e=this._routeName,filename:t}){const r=this._route.io().readSync({routeName:e,filename:t});return"string"==typeof r?JSON.parse(r||"{}"):r}async read({routeName:e=this._routeName,filename:t}){const r=await this._route.io().read({routeName:e,filename:t});return"string"==typeof r?JSON.parse(r||"{}"):r}storeSync({routeName:e=this._routeName,filename:t,data:r,force:i=!0}){const s=JSON.stringify(r,null,"\t");return this._route.io().storeSync({routeName:e,filename:t,data:s,force:i})}async store({routeName:e=this._routeName,filename:t,data:r,force:i=!0}){const s=JSON.stringify(r,null,"\t");return await this._route.io().store({routeName:e,filename:t,data:s,force:i})}removeSync({routeName:e=this._routeName,filename:t}){return this._route.io().removeSync({routeName:e,filename:t})}async remove({routeName:e=this._routeName,filename:t}){return await this._route.io().remove({routeName:e,filename:t})}}}]);
module.exports=function(e){var t={};function r(i){if(t[i])return t[i].exports;var s=t[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=e,r.c=t,r.d=function(e,t,i){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(r.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(i,s,function(t){return e[t]}.bind(null,s));return i},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){e.exports=require("path")},function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.Routes=t.Route=void 0;const s=i(r(2)),n={_routes:[],route:{},instance:Function,save:Function,load:Function};t.Routes=n;const a={};t.Route=a,n.instance=function(e,t){const r=new s.default;return r._namespace=t,e({instance:r}),n._routes.push(r),n.route[t]=r,a[t]=r,r},n.save=function({instance:e,routeName:t,filename:r,force:i=!0}){if(!(e&&e instanceof s.default))return!1;const n=e.routes();return e.json().set(t).storeSync({filename:r,data:n,force:i}),!0},n.load=function(e){const t=new s.default;let r=t.io().readSync({filename:"",folder:e});return r&&(r=JSON.parse(r),r.map(e=>t.set(e.name,e.path))),n._routes.push(t),t}},function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(r(0)),n=r(3);t.default=class{constructor(){this._routes=[],this._prefix="",this._namespace="",this._storage={},this._io=new n.FileManager(this),this._json=new n.FileJSON(this,"")}io(){return this._io}json(){return this._json}hasItem(e){return!!this._storage.hasOwnProperty(e)}setItem(e,t,r){return this.hasItem(e)&&r||(this._storage[e]=t),this._storage[e]}getItem(e){return this._storage[e]}routes(){return this._routes}has(e){return!!this._routes.find(t=>t.name===e)}remove(e){this.has(e)&&(this._routes=this._routes.filter(({name:t})=>t!==e))}set(e,t){if(this.has(e))return this.get(e);{const r={name:e,filepath:t};return this._routes.push(r),r}}get(e){const t={name:"",filepath:"",prefix:""},r=this._routes.find(({name:t})=>t===e);return r?Object.assign(t,r):t}alias(e,t){return this.has(t)&&this.set(e,this.get(t).filepath),this}join(e,t,r){if(this.has(t)){const i=this.get(t),n={name:e,filepath:s.default.join(i.filepath,r||e)};return this._routes.push(n),n}}inject(e,t,r){return this.io().hasFolder(t,r||e)||this.io().setFolder(e,r||t),this.join(e,t,r),this}prefix(e){return this._prefix=e,this._routes.forEach(t=>{t.hasOwnProperty("prefix")?t.name.replace(t.prefix||"",e):(t.name=`${e}/${t.name}`,t.prefix=e)}),this}plug(e,t){return s.default.join(this.get(e).filepath||"",t)}clean(e){return this.get(e).filepath.replace(/(\/)[(/)]/g,"/")}back(e,t=1){if(this.has(e)){const r=new Array(t).fill("..");return s.default.resolve(this.get(e).filepath,...r)}return""}endWith(e){const t=e.replace(/(\/)[(/)]/g,"/");return s.default.basename(t)}resolve(...e){return s.default.resolve(...e)}basename(e,t){return s.default.basename(e,t)}dirname(e){return s.default.dirname(e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var i=r(4);Object.defineProperty(t,"FileManager",{enumerable:!0,get:function(){return i.default}});var s=r(6);Object.defineProperty(t,"FileJSON",{enumerable:!0,get:function(){return s.default}})},function(e,t,r){"use strict";var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const s=i(r(5)),n=i(r(0));t.default=class{constructor(e){return this._route=e,this._routeName="",this._historic=[],this}setRoute(e){return this._routeName=e,this}historic(){return this._historic}setHistoric(e,t,r){const i={routeName:e,filename:t,field:r};return this._historic.push(i),this}async accessFile(e,t=["R_OK","F_OK"]){const r=t.map(e=>s.default.constants[e]).reduce((e,t)=>t|e);return await new Promise(t=>s.default.access(e,r,e=>t(!e)))}async copy(e,t){return!!await this.accessFile(t)&&(await s.default.promises.copyFile(t,this._route.plug(e,n.default.basename(t))),!0)}readSync({routeName:e=this._routeName,filename:t,folder:r}){if(!this._route.has(e)&&!r)return;const i="string"==typeof r?n.default.join(r,t):this._route.plug(e,t);if(!s.default.existsSync(i))return;this.setHistoric(e,t,"read");return s.default.readFileSync(i,"utf-8")}async read({routeName:e=this._routeName,filename:t,folder:r}){if(!this._route.has(e)&&!r)return;const i="string"==typeof r?n.default.join(r,t):this._route.plug(e,t);if(await this.accessFile(i)){this.setHistoric(e,i,"read");return await s.default.promises.readFile(i,"utf-8")}}storeSync({routeName:e=this._routeName,filename:t,force:r=!0,data:i}){if(!this._route.has(e))return!1;const n=this._route.plug(e,t);return s.default.existsSync(n)&&!r||(s.default.writeFileSync(n,i,"utf-8"),this.setHistoric(e,n,"write")),!0}async store({routeName:e=this._routeName,filename:t,force:r=!0,data:i}){if(!this._route.has(e))return!1;const n=this._route.plug(e,t);return await this.accessFile(n)&&!r||(await s.default.promises.writeFile(n,i,"utf-8"),this.setHistoric(e,t,"write")),!0}removeSync({routeName:e=this._routeName,filename:t}){if(!this._route.has(e))return!1;const r=this._route.plug(e,t);return!s.default.existsSync(r)||(s.default.unlinkSync(r),this.setHistoric(e,t,"remove"),!0)}async remove({routeName:e=this._routeName,filename:t}){if(!this._route.has(e))return!1;const r=this._route.plug(e,t);return!await this.accessFile(r)||(s.default.promises.unlink(r),this.setHistoric(e,t,"remove"),!0)}files({routeName:e=this._routeName,extension:t,options:r}){if(!this._route.has(e))return[];const i=this._route.get(e),a=i.filepath;if(!s.default.existsSync(a))return[];t&&"string"==typeof t&&(t=new RegExp(`.(${t})$`,"gi"));const o=[];return s.default.readdirSync(a,r).map(e=>{const r=n.default.join(a,e);if(!s.default.lstatSync(a).isDirectory()){let e=r.replace(/^.*[\\\/]/,""),s=n.default.extname(e);if(t&&!e.match(t))return;o.push({name:e.replace(s,""),filename:e,filepath:r,extension:s,routeName:i.name})}}),o}folders(e=this._routeName){if(!this._route.has(e))return[];const t=this._route.get(e);let r=s.default.readdirSync(t.filepath);r=r.map(e=>n.default.join(t.filepath,e)).filter(e=>s.default.lstatSync(e).isDirectory());const i=[];return r.map(e=>{const t=e.replace(/^.*[\\\/]/,"");i.push({name:t,path:e})}),i}hasFolder(e,t){if(!this._route.has(e))return!1;const r=n.default.join(this._route.get(e).filepath,t);return!!s.default.existsSync(r)&&s.default.lstatSync(r).isDirectory()}setFolder(e,t){const r=n.default.join(this._route.get(e).filepath,t);return this.hasFolder(e,t)||s.default.mkdirSync(r,{recursive:!1}),this}}},function(e,t){e.exports=require("fs")},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(e,t){return this._route=e,this._routeName=t,this}set(e){return this._routeName=e,this}readSync({routeName:e=this._routeName,filename:t}){const r=this._route.io().readSync({routeName:e,filename:t});return"string"==typeof r?JSON.parse(r||"{}"):r}async read({routeName:e=this._routeName,filename:t}){const r=await this._route.io().read({routeName:e,filename:t});return"string"==typeof r?JSON.parse(r||"{}"):r}storeSync({routeName:e=this._routeName,filename:t,data:r,force:i=!0}){const s=JSON.stringify(r,null,"\t");return this._route.io().storeSync({routeName:e,filename:t,data:s,force:i})}async store({routeName:e=this._routeName,filename:t,data:r,force:i=!0}){const s=JSON.stringify(r,null,"\t");return await this._route.io().store({routeName:e,filename:t,data:s,force:i})}removeSync({routeName:e=this._routeName,filename:t}){return this._route.io().removeSync({routeName:e,filename:t})}async remove({routeName:e=this._routeName,filename:t}){return await this._route.io().remove({routeName:e,filename:t})}}}]);
{
"name": "@vorlefan/path",
"version": "1.5.6",
"version": "1.5.61",
"description": "Easy access and handler for folders and files paths with several tools",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc