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.3.2 to 1.4.0

src/features/file.js

3

dist/index.js

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

"use strict";var e={_routes:[]},n=require("./instance");n.prototype.namespace=function(n){return e.namespace(n,this),this},e.instance=function(t){var r=new n;return t(r),e._routes.push(r),r},e.save=function(e){var t=e.instance,r=e.filename,a=e.force;return!!(t&&t instanceof n)&&(t.json({routeName:e.routeName}).storeSync({filename:r,data:t.routes(),force:a}),!0)},e.load=function(t){var r=new n,a=r._file.readSync({filename:"",folder:t});return!1!==a&&(a=JSON.parse(a)).map(function(e){return r.set(e.name,e.path)}),e._routes.push(r),r},module.exports={Routes:e,Route:{}};
//# sourceMappingURL=index.js.map
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.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.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}]);
{
"name": "@vorlefan/path",
"version": "1.3.2",
"version": "1.4.0",
"description": "Easy access and handler for folders and files paths with several tools",

@@ -20,9 +20,15 @@ "keywords": [

"devDependencies": {
"@babel/core": "^7.9.0",
"babel-loader": "^8.1.0",
"bundlesize": "^0.18.0",
"microbundle": "^0.11.0"
"jest": "^25.3.0",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11"
},
"scripts": {
"build": "microbundle src/index.js --raw --strict",
"dev": "microbundle watch",
"size": "bundlesize"
"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"
},

@@ -36,3 +42,7 @@ "source": "src/index.js",

},
"repository": "daxsoft/path_route"
"repository": "daxsoft/path_route",
"files": [
"src",
"dist"
]
}
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