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.6.8 to 1.6.9

2

dist/index.js

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

module.exports=(()=>{"use strict";var e={555:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=s(r(747)),a=s(r(622));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 s={routeName:e,filename:t,field:r};return this._historic.push(s),this}async accessFile(e,t=["R_OK","F_OK"]){const r=t.map(e=>i.default.constants[e]).reduce((e,t)=>t|e);return await new Promise(t=>i.default.access(e,r,e=>t(!e)))}async copy(e,t){return!!await this.accessFile(t)&&(await i.default.promises.copyFile(t,this._route.plug(e,a.default.basename(t))),!0)}readSync({routeName:e=this._routeName,filename:t,folder:r}){if(!this._route.has(e)&&!r)return;const s="string"==typeof r?a.default.join(r,t):this._route.plug(e,t);if(!i.default.existsSync(s))return;this.setHistoric(e,t,"read");return i.default.readFileSync(s,"utf-8")}async read({routeName:e=this._routeName,filename:t,folder:r}){if(!this._route.has(e)&&!r)return;const s="string"==typeof r?a.default.join(r,t):this._route.plug(e,t);if(await this.accessFile(s)){this.setHistoric(e,s,"read");return await i.default.promises.readFile(s,"utf-8")}}storeSync({routeName:e=this._routeName,filename:t,force:r=!0,data:s}){if(!this._route.has(e))return!1;const a=this._route.plug(e,t);return i.default.existsSync(a)&&!r||(i.default.writeFileSync(a,s,"utf-8"),this.setHistoric(e,a,"write")),!0}async store({routeName:e=this._routeName,filename:t,force:r=!0,data:s}){if(!this._route.has(e))return!1;const a=this._route.plug(e,t);return await this.accessFile(a)&&!r||(await i.default.promises.writeFile(a,s,"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!i.default.existsSync(r)||(i.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)||(i.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 s=this._route.get(e),n=s.filepath;if(!i.default.existsSync(n))return[];t&&"string"==typeof t&&(t=new RegExp(`.(${t})$`,"gi"));const o=[];return i.default.readdirSync(n,r).map(e=>{const r=a.default.join(n,e);if(!i.default.lstatSync(r).isDirectory()){let e=r.replace(/^.*[\\\/]/,""),i=a.default.extname(e);if(t&&!e.match(t))return;o.push({name:e.replace(i,""),filename:e,filepath:r,extension:i,routeName:s.name})}}),o}lastFiles({routeName:e=this._routeName,extension:t,options:r}){return this.files({routeName:e,extension:t,options:r}).sort((e,t)=>i.default.statSync(t.filepath).mtimeMs-i.default.statSync(e.filepath).mtimeMs)}folders(e=this._routeName){if(!this._route.has(e))return[];const t=this._route.get(e);let r=i.default.readdirSync(t.filepath);r=r.map(e=>a.default.join(t.filepath,e)).filter(e=>i.default.lstatSync(e).isDirectory());const s=[];return r.map(e=>{const t=e.replace(/^.*[\\\/]/,"");s.push({name:t,path:e})}),s}hasFolder(e){return!!i.default.existsSync(e)&&i.default.lstatSync(e).isDirectory()}setFolder(e,t){const r=a.default.join(this._route.get(e).filepath,t);return this.hasFolder(this._route.plug(e,t))||i.default.mkdirSync(r,{recursive:!1}),this}}},582:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FileStream=t.FileJSON=t.FileManager=void 0;var i=r(555);Object.defineProperty(t,"FileManager",{enumerable:!0,get:function(){return s(i).default}});var a=r(207);Object.defineProperty(t,"FileJSON",{enumerable:!0,get:function(){return s(a).default}});var n=r(474);Object.defineProperty(t,"FileStream",{enumerable:!0,get:function(){return s(n).default}})},207:(e,t)=>{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:s=!0}){const i=JSON.stringify(r,null,"\t");return this._route.io().storeSync({routeName:e,filename:t,data:i,force:s})}async store({routeName:e=this._routeName,filename:t,data:r,force:s=!0}){const i=JSON.stringify(r,null,"\t");return await this._route.io().store({routeName:e,filename:t,data:i,force:s})}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})}}},474:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=s(r(747)),a=s(r(605)),n=s(r(211));t.default=class{constructor(e){return this._route=e,this._routeName="",this}async download({url:e,destination:t,protocol:r="http"}){return new Promise((s,o)=>{const u=i.default.createWriteStream(t);("http"===r?a.default:n.default).get(e,e=>{e.pipe(u),u.on("finish",()=>{u.close(),s(!0)}).on("error",()=>{i.default.unlinkSync(t),o(!1)})})})}}},607:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PathRoute=t.Routes=t.Route=void 0;const i=s(r(868));t.PathRoute=i.default;const a={_routes:[],route:{}};t.Routes=a;const n={};t.Route=n,a.instance=function(e,t){const r=new i.default;r._namespace=t;return e({instance:r}),a._routes.push(r),a.route[t]=r,n[t]=r,r},a.save=function({instance:e,routeName:t,filename:r,force:s=!0}){if(!(e&&e instanceof i.default))return!1;const a=e.routes();return e.json().set(t).storeSync({filename:r,data:a,force:s}),!0},a.load=function(e){const t=new i.default;let r=t.io().readSync({filename:"",folder:e});return r&&(r=JSON.parse(r),r.map(e=>t.set(e.name,e.filepath))),a._routes.push(t),t}},868:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=s(r(622)),a=r(582);t.default=class{constructor(){this._routes=[],this._prefix="",this._namespace="",this._storage={},this._io=new a.FileManager(this),this._json=new a.FileJSON(this,""),this._stream=new a.FileStream(this)}io(){return this._io}json(){return this._json}stream(){return this._stream}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)){const r={name:e,filepath:t};this._routes.push(r)}return this}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 s=this.get(t),a={name:e,filepath:i.default.join(s.filepath,r||e)};this._routes.push(a)}return this}inject(e,t,r){if(this.has(e))return this;const s=r||e;return this.io().setFolder(t,s),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 i.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 i.default.resolve(this.get(e).filepath,...r)}return""}endWith(e){const t=e.replace(/(\/)[(/)]/g,"/");return i.default.basename(t)}sliceTo({filepath:e,routeName:t,strict:r=!1,to:s}){if(!this.has(t))return"";let a=(e||this.get(t).filepath).split(/(\/|\\)/gimu);const n=[],o=a.length;for(let e=0;e<o;e++){const t=a[e];if(n.push(t),r){if(t===s)break}else{if(new RegExp(`(${s})`,"giu").test(t))break}}return i.default.join(...n)}hierarchy(e){const t={};if(!this.has(e))return t;const{filepath:r}=this.get(e);return r.replace(/(\/|\/\/|\\|\\\\)/g," ").split(" ").map((r,s,i)=>{let a=i[s-1];const n=i.length-s;t[r]={path:this.back(e,n),index:n,next:"",parent:""},t.hasOwnProperty(a)&&(t[r].parent=a,t[a].next=r)}),t}resolve(...e){return i.default.resolve(...e)}basename(e,t){return i.default.basename(e,t)}dirname(e){return i.default.dirname(e)}}},747:e=>{e.exports=require("fs")},605:e=>{e.exports=require("http")},211:e=>{e.exports=require("https")},622:e=>{e.exports=require("path")}},t={};return function r(s){if(t[s])return t[s].exports;var i=t[s]={exports:{}};return e[s].call(i.exports,i,i.exports,r),i.exports}(607)})();
module.exports=(()=>{"use strict";var e={555:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=s(r(747)),a=s(r(622));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 s={routeName:e,filename:t,field:r};return this._historic.push(s),this}async accessFile(e,t=["R_OK","F_OK"]){const r=t.map(e=>i.default.constants[e]).reduce((e,t)=>t|e);return await new Promise(t=>i.default.access(e,r,e=>t(!e)))}async copy(e,t){return!!await this.accessFile(t)&&(await i.default.promises.copyFile(t,this._route.plug(e,a.default.basename(t))),!0)}readSync({routeName:e=this._routeName,filename:t,folder:r}){if(!this._route.has(e)&&!r)return;const s="string"==typeof r?a.default.join(r,t):this._route.plug(e,t);if(!i.default.existsSync(s))return;this.setHistoric(e,t,"read");return i.default.readFileSync(s,"utf-8")}async read({routeName:e=this._routeName,filename:t,folder:r}){if(!this._route.has(e)&&!r)return;const s="string"==typeof r?a.default.join(r,t):this._route.plug(e,t);if(await this.accessFile(s)){this.setHistoric(e,s,"read");return await i.default.promises.readFile(s,"utf-8")}}storeSync({routeName:e=this._routeName,filename:t,force:r=!0,data:s}){if(!this._route.has(e))return!1;const a=this._route.plug(e,t);return i.default.existsSync(a)&&!r||(i.default.writeFileSync(a,s,"utf-8"),this.setHistoric(e,a,"write")),!0}async store({routeName:e=this._routeName,filename:t,force:r=!0,data:s}){if(!this._route.has(e))return!1;const a=this._route.plug(e,t);return await this.accessFile(a)&&!r||(await i.default.promises.writeFile(a,s,"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!i.default.existsSync(r)||(i.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)||(i.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 s=this._route.get(e),n=s.filepath;if(!i.default.existsSync(n))return[];t&&"string"==typeof t&&(t=new RegExp(`.(${t})$`,"gi"));const o=[];return i.default.readdirSync(n,r).map(e=>{const r=a.default.join(n,e);if(!i.default.lstatSync(r).isDirectory()){let e=r.replace(/^.*[\\\/]/,""),i=a.default.extname(e);if(t&&!e.match(t))return;o.push({name:e.replace(i,""),filename:e,filepath:r,extension:i,routeName:s.name})}}),o}lastFiles({routeName:e=this._routeName,extension:t,options:r}){return this.files({routeName:e,extension:t,options:r}).sort((e,t)=>i.default.statSync(t.filepath).mtimeMs-i.default.statSync(e.filepath).mtimeMs)}folders(e=this._routeName){if(!this._route.has(e))return[];const t=this._route.get(e);let r=i.default.readdirSync(t.filepath);r=r.map(e=>a.default.join(t.filepath,e)).filter(e=>i.default.lstatSync(e).isDirectory());const s=[];return r.map(e=>{const t=e.replace(/^.*[\\\/]/,"");s.push({name:t,path:e})}),s}hasFolder(e){return!!i.default.existsSync(e)&&i.default.lstatSync(e).isDirectory()}setFolder(e,t){const r=a.default.join(this._route.get(e).filepath,t);return this.hasFolder(this._route.plug(e,t))||i.default.mkdirSync(r,{recursive:!1}),this}}},582:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.FileStream=t.FileJSON=t.FileManager=void 0;var i=r(555);Object.defineProperty(t,"FileManager",{enumerable:!0,get:function(){return s(i).default}});var a=r(207);Object.defineProperty(t,"FileJSON",{enumerable:!0,get:function(){return s(a).default}});var n=r(474);Object.defineProperty(t,"FileStream",{enumerable:!0,get:function(){return s(n).default}})},207:(e,t)=>{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:s=!0}){const i=JSON.stringify(r,null,"\t");return this._route.io().storeSync({routeName:e,filename:t,data:i,force:s})}async store({routeName:e=this._routeName,filename:t,data:r,force:s=!0}){const i=JSON.stringify(r,null,"\t");return await this._route.io().store({routeName:e,filename:t,data:i,force:s})}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})}}},474:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=s(r(747)),a=s(r(605)),n=s(r(211));t.default=class{constructor(e){return this._route=e,this._routeName="",this}async download({url:e,destination:t,protocol:r="http"}){return new Promise((s,o)=>{const u=i.default.createWriteStream(t);("http"===r?a.default:n.default).get(e,e=>{e.pipe(u),u.on("finish",()=>{u.close(),s(!0)}).on("error",()=>{i.default.unlinkSync(t),o(!1)})})})}}},607:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.PathRoute=t.Routes=t.Route=void 0;const i=s(r(868));t.PathRoute=i.default;const a={_routes:[],route:{}};t.Routes=a;const n={};t.Route=n,a.instance=function(e,t){const r=new i.default;r._namespace=t;return e({instance:r}),a._routes.push(r),a.route[t]=r,n[t]=r,r},a.save=function({instance:e,routeName:t,filename:r,force:s=!0}){if(!(e&&e instanceof i.default))return!1;const a=e.routes();return e.json().set(t).storeSync({filename:r,data:a,force:s}),!0},a.load=function(e){const t=new i.default;let r=t.io().readSync({filename:"",folder:e});return r&&(r=JSON.parse(r),r.map(e=>t.set(e.name,e.filepath))),a._routes.push(t),t}},868:function(e,t,r){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=s(r(622)),a=r(582);t.default=class{constructor(){this._routes=[],this._prefix="",this._namespace="",this._storage={},this._io=new a.FileManager(this),this._json=new a.FileJSON(this,""),this._stream=new a.FileStream(this)}io(){return this._io}json(){return this._json}stream(){return this._stream}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)){const r={name:e,filepath:t};this._routes.push(r)}return this}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 s=this.get(t),a={name:e,filepath:i.default.join(s.filepath,r||e)};this._routes.push(a)}return this}inject(e,t,r){if(this.has(e))return this;const s=r||e;return this.io().setFolder(t,s),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 i.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 i.default.resolve(this.get(e).filepath,...r)}return""}endWith(e){const t=e.replace(/(\/)[(/)]/g,"/");return i.default.basename(t)}sliceTo({filepath:e,routeName:t,strict:r=!1,to:s}){if(!this.has(t))return"";let a=(e||this.get(t).filepath).split(/(\/|\\)/gimu);const n=[],o=a.length;for(let e=0;e<o;e++){const t=a[e];if(n.push(t),r){if(t===s)break}else{if(new RegExp(`(${s})`,"giu").test(t))break}}return i.default.join(...n)}hierarchy(e){const t={};if(!this.has(e))return t;const{filepath:r}=this.get(e);return r.replace(/(\/|\/\/|\\|\\\\)/g," ").split(" ").map((r,s,i)=>{let a=i[s-1];const n=i.length-s;t[r]={path:this.back(e,n),index:n,next:"",parent:"",current:r},t.hasOwnProperty(a)&&(t[r].parent=a,t[a].next=r)}),t}resolve(...e){return i.default.resolve(...e)}basename(e,t){return i.default.basename(e,t)}dirname(e){return i.default.dirname(e)}}},747:e=>{e.exports=require("fs")},605:e=>{e.exports=require("http")},211:e=>{e.exports=require("https")},622:e=>{e.exports=require("path")}},t={};return function r(s){if(t[s])return t[s].exports;var i=t[s]={exports:{}};return e[s].call(i.exports,i,i.exports,r),i.exports}(607)})();
//# sourceMappingURL=index.js.map

@@ -69,2 +69,3 @@ import PathRoute from './instance';

next: string;
current: string;
}
{
"name": "@vorlefan/path",
"version": "1.6.8",
"version": "1.6.9",
"description": "Easy access and handler for folders and files paths with several tools",

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

Sorry, the diff of this file is not supported yet

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