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.3 to 1.5.4

dist/features/file.d.ts

4

changelog.md

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

# 1.5.4
- Change from ESBUILD to Webpack
# 1.5.3

@@ -2,0 +6,0 @@

2

dist/index.js

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

let e$=Object.defineProperty,f$=Object.hasOwnProperty,h$={},j$,k$=a$=>{let b$=h$[a$];return b$||(b$=h$[a$]={exports:{}},j$[a$](b$.exports,b$)),b$.exports},l$=a$=>{if(a$&&a$.__esModule)return a$;let b$={};for(let c$ in a$)f$.call(a$,c$)&&(b$[c$]=a$[c$]);return b$.default=a$,b$},p$=a$=>l$(k$(a$)),q$=(a$,b$)=>{e$(a$,"__esModule",{value:!0});for(let c$ in b$)e$(a$,c$,{get:b$[c$],enumerable:!0})};j$={4(u){const C=l$(require("fs")),D=l$(require("path"));"use strict";class q{constructor(a){return this._route=a,this._routeName="",this._historic=[],this}setRoute(a){return this._routeName=a,this}historic(){return this._historic}setHistoric(a,b,c){const d={routeName:a,filename:b,field:c};return this._historic.push(d),this}async accessFile(a,b=["R_OK","F_OK"]){const c=b.map(d=>C.default.constants[d]).reduce((d,e)=>e|d);return await new Promise(()=>{C.default.promises.access(a,c).then(()=>!0).catch(()=>!1)})}async copy(a,b){const c=await this.accessFile(b);return c?(await C.default.promises.copyFile(b,this._route.plug(a,D.default.basename(b))),!0):!1}readSync({routeName:a=this._routeName,filename:b,folder:c}){if(!this._route.has(a)&&!c)return;const d=typeof c==="string"?D.default.join(c,b):this._route.plug(a,b);if(!C.default.existsSync(d))return;this.setHistoric(a,b,"read");const e=C.default.readFileSync(d,"utf-8");return e}async read({routeName:a=this._routeName,filename:b,folder:c}){if(!this._route.has(a)&&!c)return;const d=typeof c==="string"?D.default.join(c,b):this._route.plug(a,b),e=await this.accessFile(d);if(e){this.setHistoric(a,d,"read");const g=await C.default.promises.readFile(d,"utf-8");return g}return}storeSync({routeName:a=this._routeName,filename:b,force:c=!0,data:d}){if(!this._route.has(a))return!1;const e=this._route.plug(a,b),g=C.default.existsSync(e);return g&&!c?!0:(C.default.writeFileSync(e,d,"utf-8"),this.setHistoric(a,e,"write"),!0)}async store({routeName:a=this._routeName,filename:b,force:c=!0,data:d}){if(!this._route.has(a))return!1;const e=this._route.plug(a,b),g=await this.accessFile(e);return g&&!c?!0:(await C.default.promises.writeFile(e,d,"utf-8"),this.setHistoric(a,b,"write"),!0)}removeSync({routeName:a=this._routeName,filename:b}){if(!this._route.has(a))return!1;const c=this._route.plug(a,b);return C.default.existsSync(c)?(C.default.unlinkSync(c),this.setHistoric(a,b,"remove"),!0):!0}async remove({routeName:a=this._routeName,filename:b}){if(!this._route.has(a))return!1;const c=this._route.plug(a,b),d=await this.accessFile(c);return d?(C.default.promises.unlink(c),this.setHistoric(a,b,"remove"),!0):!0}async files({routeName:a=this._routeName,extension:b,options:c}){if(!this._route.has(a))return[];const d=this._route.get(a),e=d.filepath,g=await this.accessFile(e);if(!g)return[];!!b&&typeof b==="string"&&(b=new RegExp(`.(${b})$`,"gi"));const k=[],w=await C.default.promises.readdir(e,c);return await Promise.all(w.map(async x=>{const o=D.default.join(e,x),y=await C.default.promises.lstat(e);if(!y.isDirectory()){let l=o.replace(/^.*[\\\/]/,""),p=D.default.extname(l);if(b&&!l.match(b))return;k.push({name:l.replace(p,""),filename:l,filepath:o,extension:p,routeName:d.name})}})),k}async folders(a=this._routeName){if(!this._route.has(a))return[];const b=this._route.get(a),c=g=>C.default.lstatSync(g).isDirectory();let d=await C.default.promises.readdir(b.filepath);d=d.map(g=>D.default.join(b.filepath,g)).filter(c);const e=[];return d.map(g=>{const k=g.replace(/^.*[\\\/]/,"");e.push({name:k,path:g})}),e}hasFolder(a,b){if(!this._route.has(a))return!1;const c=D.default.join(this._route.get(a).filepath,b);return!!C.default.existsSync(c)&&C.default.lstatSync(c).isDirectory()}setFolder(a,b){const c=D.default.join(this._route.get(a).filepath,b);return this.hasFolder(a,b)||C.default.mkdirSync(c,{recursive:!1}),this}}const r=q;"use strict";class s{constructor(a,b){return this._route=a,this._routeName=b,this}set(a){return this._routeName=a,this}readSync({routeName:a=this._routeName,filename:b}){const c=this._route.io().readSync({routeName:a,filename:b}),d=typeof c==="string"?JSON.parse(c||"{}"):c;return d}async read({routeName:a=this._routeName,filename:b}){const c=await this._route.io().read({routeName:a,filename:b}),d=typeof c==="string"?JSON.parse(c||"{}"):c;return d}storeSync({routeName:a=this._routeName,filename:b,data:c,force:d=!0}){const e=JSON.stringify(c,null," "),g=this._route.io().storeSync({routeName:a,filename:b,data:e,force:d});return g}async store({routeName:a=this._routeName,filename:b,data:c,force:d=!0}){const e=JSON.stringify(c,null," "),g=await this._route.io().store({routeName:a,filename:b,data:e,force:d});return g}removeSync({routeName:a=this._routeName,filename:b}){const c=this._route.io().removeSync({routeName:a,filename:b});return c}async remove({routeName:a=this._routeName,filename:b}){const c=await this._route.io().remove({routeName:a,filename:b});return c}}const t=s;"use strict";const W=l$(require("path"));"use strict";class v{constructor(){this._routes=[],this._prefix="",this._namespace="",this._storage={},this._io=new r(this),this._json=new t(this,"")}io(){return this._io}json(){return this._json}hasItem(a){return!!this._storage.hasOwnProperty(a)}setItem(a,b,c){return this.hasItem(a)&&!!c||(this._storage[a]=b),this._storage[a]}getItem(a){return this._storage[a]}routes(){return this._routes}has(a){const b=this._routes.find(c=>c.name===a);return!!b}remove(a){if(!this.has(a))return;this._routes=this._routes.filter(({name:b})=>b!==a)}set(a,b){if(this.has(a))return this.get(a);{const c={name:a,filepath:b};return this._routes.push(c),c}}get(a){const b={name:"",filepath:"",prefix:""},c=this._routes.find(({name:d})=>d===a);return c?Object.assign(b,c):b}alias(a,b){return this.has(b)&&this.set(a,this.get(b).filepath),this}join(a,b,c){if(this.has(b)){const d=this.get(b),e={name:a,filepath:W.default.join(d.filepath,c||a)};return this._routes.push(e),e}}inject(a,b,c){const d=this.io().hasFolder(b,c||a);return d||this.io().setFolder(a,c||b),this.join(a,b,c),this}prefix(a){return this._prefix=a,this._routes.forEach(b=>{b.hasOwnProperty("prefix")?b.name.replace(b.prefix||"",a):(b.name=`${a}/${b.name}`,b.prefix=a)}),this}plug(a,b){return W.default.join(this.get(a).filepath||"",b)}clean(a){return this.get(a).filepath.replace(/(\/)[(/)]/g,"/")}back(a,b=1){if(this.has(a)){const c=new Array(b).fill("..");return W.default.resolve(this.get(a).filepath,...c)}return""}endWith(a){const b=a.replace(/(\/)[(/)]/g,"/");return W.default.basename(b)}resolve(...a){return W.default.resolve(...a)}basename(a,b){return W.default.basename(a,b)}dirname(a){return W.default.dirname(a)}}const m=v;q$(u,{Route:()=>n,Routes:()=>i});"use strict";const i={_routes:[],route:{},instance:Function,save:Function,load:Function},n={};i.instance=function a(b,c){const d=new m();return d._namespace=c,b({instance:d}),i._routes.push(d),i.route[c]=d,n[c]=d,d},i.save=function({instance:a,routeName:b,filename:c,force:d=!0}){if(!a||!(a instanceof m))return!1;const e=a.routes();return a.json().set(b).storeSync({filename:c,data:e,force:d}),!0},i.load=function(a){const b=new m();let c=b.io().readSync({filename:"",folder:a});return c&&(c=JSON.parse(c),c.map(d=>b.set(d.name,d.path))),i._routes.push(b),b}}};module.exports=k$(4);
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)),a={_routes:[],route:{},instance:Function,save:Function,load:Function};t.Routes=a;const n={};t.Route=n,a.instance=function(e,t){const r=new s.default;return r._namespace=t,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:i=!0}){if(!(e&&e instanceof s.default))return!1;const a=e.routes();return e.json().set(t).storeSync({filename:r,data:a,force:i}),!0},a.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))),a._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)),a=r(3);t.default=class{constructor(){this._routes=[],this._prefix="",this._namespace="",this._storage={},this._io=new a.FileManager(this),this._json=new a.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),a={name:e,filepath:s.default.join(i.filepath,r||e)};return this._routes.push(a),a}}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)),a=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(()=>{s.default.promises.access(e,r).then(()=>!0).catch(()=>!1)})}async copy(e,t){return!!await this.accessFile(t)&&(await s.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 i="string"==typeof r?a.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?a.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 a=this._route.plug(e,t);return s.default.existsSync(a)&&!r||(s.default.writeFileSync(a,i,"utf-8"),this.setHistoric(e,a,"write")),!0}async store({routeName:e=this._routeName,filename:t,force:r=!0,data:i}){if(!this._route.has(e))return!1;const a=this._route.plug(e,t);return await this.accessFile(a)&&!r||(await s.default.promises.writeFile(a,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)}async files({routeName:e=this._routeName,extension:t,options:r}){if(!this._route.has(e))return[];const i=this._route.get(e),n=i.filepath;if(!await this.accessFile(n))return[];t&&"string"==typeof t&&(t=new RegExp(`.(${t})$`,"gi"));const o=[],u=await s.default.promises.readdir(n,r);return await Promise.all(u.map(async e=>{const r=a.default.join(n,e);if(!(await s.default.promises.lstat(n)).isDirectory()){let e=r.replace(/^.*[\\\/]/,""),s=a.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}async folders(e=this._routeName){if(!this._route.has(e))return[];const t=this._route.get(e);let r=await s.default.promises.readdir(t.filepath);r=r.map(e=>a.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=a.default.join(this._route.get(e).filepath,t);return!!s.default.existsSync(r)&&s.default.lstatSync(r).isDirectory()}setFolder(e,t){const r=a.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.3",
"version": "1.5.4",
"description": "Easy access and handler for folders and files paths with several tools",

@@ -22,2 +22,3 @@ "main": "dist/index.js",

"devDependencies": {
"@babel/core": "^7.9.0",
"@types/jest": "^25.2.3",

@@ -27,2 +28,3 @@ "@types/node": "^14.0.4",

"@typescript-eslint/parser": "^2.34.0",
"babel-loader": "^8.1.0",
"bundlesize": "^0.18.0",

@@ -36,3 +38,6 @@ "esbuild": "^0.3.5",

"ts-jest": "^26.0.0",
"typescript": "^3.9.3"
"ts-loader": "^7.0.4",
"typescript": "^3.9.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
},

@@ -43,3 +48,3 @@ "publishConfig": {

"scripts": {
"build": "node esbuild.ts & yarn run size",
"build": "webpack --mode production & yarn run size",
"lint": "eslint './src/**/*.{js,ts,tsx}'",

@@ -46,0 +51,0 @@ "test": "jest",

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