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.4.1 to 1.5.1

4

changelog.md

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

# 1.5.0
- TypeScript version
# 1.4.1

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

2

dist/index.js

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

module.exports=function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e){t.exports=require("fs")},function(t,e){t.exports=require("path")},function(t,e,r){"use strict";const o={_routes:[],route:{}},n={},i=r(3);i.prototype.namespace=function(t){return this._namespace=t,o.route[t]=this,n[t]=this,this},o.instance=function(t){const e=new i;return t(e),o._routes.push(e),e},o.save=function({instance:t,routeName:e,filename:r,force:o}){return!!(t&&t instanceof i)&&(t.json({routeName:e}).storeSync({filename:r,data:t.routes(),force:o}),!0)},o.load=function(t){const e=new i;let r=e._file.readSync({filename:"",folder:t});return!1!==r&&(r=JSON.parse(r),r.map(t=>e.set(t.name,t.path))),o._routes.push(e),e},t.exports={Routes:o,Route:n}},function(t,e,r){"use strict";const o=r(0),n=r(1),{FileJSON:i,FileManager:s}=r(4);function u(){this.initialize.apply(this,arguments)}u.prototype=Object.create(u),u.prototype.constructor=u,u.prototype.initialize=function(){this._routes=[],this._prefix="",this._namespace="",this._storage={},this._file=new s(this)},u.prototype.io=function(){return this._file},u.prototype.setItem=function(t,e,r=!1){return this._storage.hasOwnProperty(t)&&r?this._storage[t]:this._storage[t]=e},u.prototype.getItem=function(t){return this._storage[t]},u.prototype.set=function(t,e){if(this.has(t))return this.get(t);{const r={name:t,path:e};return this._routes.push(r),r}},u.prototype.alias=function(t,e){if(this.has(e))return this.set(t,this.get(e).path),this},u.prototype.get=function(t){return this._routes.find(e=>e.name===t)},u.prototype.join=function(t,e,r){if(this.has(e)){e=this.get(e);const o={name:t,path:n.join(e.path,r||t)};return this._routes.push(o),o}},u.prototype.inject=function(t,e,r=null){return this.hasFolder(e,r||t)||this.setFolder(e,r||t),this.join(t,e,r),this},u.prototype.has=function(t){return!!this._routes.find(e=>e.name===t)},u.prototype.prefix=function(t){return this._prefix=t,this._routes.forEach(e=>{e.hasOwnProperty("prefix")?e.name.replace(e.prefix,t):(e.name=`${t}/${e.name}`,e.prefix=t)}),this},u.prototype.routes=function(){return this._routes},u.prototype.plug=function(t,e){return n.join(this.get(t).path,e)},u.prototype.clean=function(t){return this.get(t).path.replace(/(\/)[(/)]/g,"/")},u.prototype.back=function(t,e=1){if(this.has(t)){const r=new Array(e).fill("..");return n.resolve(this.get(t).path,...r)}return null},u.prototype.endWith=function(t){const e=t.replace(/(\/)[(/)]/g,"/");return n.basename(e)},u.prototype.resolve=function(...t){return n.resolve(...t)},u.prototype.basename=function(...t){return n.basename(...t)},u.prototype.dirname=function(...t){return n.dirname(...t)},u.prototype.files=function(t,e){if(!this.has(t))return[];const r=this.get(t);if(!o.existsSync(r.path))return[];"string"==typeof e&&(e=new RegExp(`.(${e})$`,"gi"));const i=[],s=o.readdirSync(r.path);let u=s.length;for(;u--;){const a=n.join(r.path,s[u]);if(!o.lstatSync(a).isDirectory()){let r=a.replace(/^.*[\\\/]/,""),o=n.extname(r);if(e&&"string"==typeof e&&!r.match(e))continue;i.push({name:r.replace(o,""),filename:r,path:a,extension:o,routeName:t})}}return i},u.prototype.json=function({routeName:t}){return new i(this,{routeName:t})},u.prototype.folders=function(t,e){if(!this.has(t))return[];const r=this.get(t),i=o.readdirSync(r.path).map(t=>n.join(r.path,t)).filter(t=>o.lstatSync(t).isDirectory()),s=[];return e&&e instanceof RegExp?i.filter(t=>e.test(t.replace(/^.*[\\\/]/,""))).map(t=>{s.push({name:t.replace(/^.*[\\\/]/,""),path:t})}):i.map(t=>{s.push({name:t.replace(/^.*[\\\/]/,""),path:t})}),s},u.prototype.setFolder=function(t,e){return this.hasFolder(t,e)||o.mkdirSync(n.join(this.get(t).path,e),!1),this},u.prototype.hasFolder=function(t,e){return this.folders(t).find(t=>t.name===e)},t.exports=u},function(t,e,r){"use strict";const o=r(5),n=r(6);t.exports={FileJSON:o,FileManager:n}},function(t,e,r){"use strict";function o(){this.initialize.apply(this,arguments)}o.prototype=Object.create(o),o.prototype.constructor=o,o.prototype.initialize=function(t,{routeName:e}){return this._route=t,this._routeName=e,this._file=this._route._file,this},o.prototype.setRoute=function(t){return this._routeName=t,this},o.prototype.readSync=function({route:t=this._routeName,filename:e}){const r=this._file.readSync({route:t,filename:e});return"string"==typeof r?JSON.parse(r):r},o.prototype.read=async function({route:t=this._routeName,filename:e}){const r=await this._file.read({route:t,filename:e});return"string"==typeof r?JSON.parse(r):r},o.prototype.storeSync=function({route:t=this._routeName,filename:e,data:r,force:o=!0}){return this._file.storeSync({route:t,filename:e,data:JSON.stringify(r,null,"\t"),force:o})},o.prototype.store=async function({route:t=this._routeName,filename:e,data:r,force:o=!0}){return await this._file.store({route:t,filename:e,data:JSON.stringify(r,null,"\t"),force:o})},o.prototype.dispose=function({route:t=this._routeName,filename:e}){return this._file.dispose({route:t,filename:e})},t.exports=o},function(t,e,r){"use strict";const o=r(0),n=o.promises,i=r(1);function s(){this.initialize.apply(this,arguments)}s.prototype=Object.create(s),s.prototype.constructor=s,s.prototype.initialize=function(t){return this._route=t,this._routeName="",this._historic=[],this},s.prototype.setRoute=function(t){return this._routeName=t,this},s.prototype.last=function(){return[...this._historic].pop()},s.prototype.historic=function(){return[...this._historic]},s.prototype.setHistoric=function(t,e,r){const o={route:t,filename:e,type:r};return this._historic.push(o),this},s.prototype.accessFile=async function(t,e=["R_OK","F_OK"]){const r=e.map(t=>o.constants[t]).reduce((t,e)=>e|t);return await new Promise((e,o)=>{n.access(t,r).then(e(!0)).catch(o(!1))})},s.prototype.copy=async function(t,e){return!!await this.accessFile(e)&&(await n.copyFile(e,this._route.plug(t,i.basename(e))),!0)},s.prototype.readSync=function({route:t=this._routeName,filename:e,folder:r=null}){if(!this._route.has(t)&&null===r)return;const n="string"==typeof r?i.join(r,e):this._route.plug(t,e);return!!o.existsSync(n)&&(this.setHistoric(t,e,"read"),o.readFileSync(n,"utf8"))},s.prototype.read=async function({route:t=this._routeName,filename:e,folder:r=null}){if(!this._route.has(t))return;const o="string"==typeof r?i.join(r,e):this._route.plug(t,e);return!!await this.accessFile(o)&&(this.setHistoric(t,e,"read"),await n.readFile(o,"utf8"))},s.prototype.storeSync=function({route:t=this._routeName,filename:e,force:r=!0,data:n}){if(!this._route.has(t))return;const i=this._route.plug(t,e);return o.existsSync(i)&&!r||(o.writeFileSync(i,n,"utf8"),this.setHistoric(t,e,"write")),!0},s.prototype.store=async function({route:t=this._routeName,filename:e,force:r=!0,data:i}){if(!this._route.has(t))return;const s=this._route.plug(t,e);return o.existsSync(s)&&!r||(await n.writeFile(s,i,"utf8"),this.setHistoric(t,e,"write")),!0},s.prototype.disposeSync=function({route:t=this._routeName,filename:e}){if(!this._route.has(t))return;const r=this._route.plug(t,e);return!o.existsSync(r)||(this.setHistoric(t,e,"delete"),o.unlinkSync(r))},t.exports=s}]);
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.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}setItem(a,b,c){return this._storage.hasOwnProperty(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(b,c||a),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 null}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);
{
"name": "@vorlefan/path",
"version": "1.4.1",
"version": "1.5.1",
"description": "Easy access and handler for folders and files paths with several tools",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": {
"name": "Michael Willian Santos",
"email": "dax-soft@live.com",
"url": "https://daxsoft.github.io/"
},
"keywords": [

@@ -12,36 +19,36 @@ "path",

],
"author": {
"name": "Michael Willian Santos",
"email": "dax-soft@live.com",
"url": "https://daxsoft.github.io/"
},
"license": "MIT",
"private": false,
"devDependencies": {
"@babel/core": "^7.9.0",
"babel-loader": "^8.1.0",
"@types/jest": "^25.2.3",
"@types/node": "^14.0.4",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"bundlesize": "^0.18.0",
"jest": "^25.3.0",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
"esbuild": "^0.3.5",
"eslint": "^7.0.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.3",
"jest": "^26.0.1",
"nodemon": "^2.0.4",
"ts-jest": "^26.0.0",
"typescript": "^3.9.3"
},
"scripts": {
"build": "webpack --mode production",
"size": "bundlesize",
"test": "jest test & bundlesize",
"regula": "node .regula/src/start/index.js",
"@vorlefan/clear-console": "node .regula/src/command/default/src/index.js"
},
"source": "src/index.js",
"main": "dist/index.js",
"module": "dist/index.modern.module.js",
"unpkg": "index.umd.js",
"publishConfig": {
"access": "public"
},
"repository": "daxsoft/path_route",
"scripts": {
"build": "node esbuild.ts & yarn run size",
"lint": "eslint './src/**/*.{js,ts,tsx}'",
"test": "jest",
"test:watch": "jest --watchAll",
"watch": "tsc -w",
"start": "npm link && nodemon",
"semantic-release": "semantic-release",
"size": "bundlesize"
},
"files": [
"src",
"dist"
]
"dist/**/*"
],
"repository": "daxsoft/path_route"
}
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