easypathutil
Advanced tools
Comparing version 1.1.1 to 1.2.0
'use strict'; | ||
Reflect.defineProperty(exports, '__esModule', { value: true }); | ||
module.exports = require('./src/struct/PathBuilder').default; | ||
const PathBuilder = require('./src/struct/PathBuilder').default; | ||
const version = PathBuilder(__dirname)['package.json'].$json.version; | ||
Object.defineProperties(PathBuilder, { | ||
version: { value: version }, | ||
VERSION: { value: version }, | ||
}); | ||
module.exports = PathBuilder; |
{ | ||
"name": "easypathutil", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Fluent filepaths, made simple.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node index.js" | ||
"test": "node index.js", | ||
"lint": "eslint ." | ||
}, | ||
@@ -9,0 +10,0 @@ "repository": { |
@@ -22,5 +22,10 @@ <div align="center"> | ||
npm install easypathutil@1.1.1 | ||
npm install easypathutil@1.2.0 | ||
## New in 1.1.0 | ||
### New in 1.2.0 | ||
• Completely refactored internals that power the fluent API | ||
• Provide your own Promise library | ||
### New in 1.1.0 | ||
• Provide your own JSON, path, or fs objects | ||
@@ -40,3 +45,3 @@ | ||
• Lightweight: Package size under 7kB | ||
• Updated and Lightweight: Package size ~7kB | ||
@@ -82,2 +87,3 @@ The tutorial below aims to demonstrate the core functionality of this package. | ||
path: somePathPackage || require('path'), | ||
Promise: somePromisePackage || global.Promise, | ||
}); | ||
@@ -111,5 +117,5 @@ | ||
// The following will hence be true or resolve to true: | ||
myjsfilebuffer === await myjsfilebufferpromise | ||
myjsfilebuffer !== await myjsfilebufferpromise | ||
myjsfilebuffer.toString() === (await myjsfilebufferpromise).toString() | ||
myjsfilebufferpromise.then(filedata => filedata === myjsfilebuffer) | ||
myjsfilebufferpromise.then(filedata => filedata !== myjsfilebuffer) | ||
myjsfilebufferpromise.then(filedata => filedata.toString() === myjsfilebuffer.toString()) | ||
@@ -189,2 +195,7 @@ | ||
**Version** | ||
const version = require('easypathutil').version; | ||
version === require('easypathutil').VERSION; | ||
This package adapts as needs arise, and although it has been tested on some versions of node v8 and v10, problems may still occur. | ||
@@ -191,0 +202,0 @@ |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const { traps: { has, get } } = require('../deps'); | ||
const ReadHelper = require('./ReadHelper').default; | ||
@@ -11,4 +12,5 @@ function PathBuilder(base = process.cwd(), { | ||
fs = require('fs'), | ||
Promise = global.Promise, | ||
} = {}, parts = []) { | ||
if (!(this instanceof PathBuilder)) return new PathBuilder(base, { JSON, path, fs }, parts); | ||
if (!(this instanceof PathBuilder)) return new PathBuilder(base, { JSON, path, fs, Promise }, parts); | ||
this.base = base; | ||
@@ -19,2 +21,4 @@ this.parts = parts; | ||
this._fs = fs; | ||
this._Promise = Promise; | ||
this.read_dir = new ReadHelper(this, { fs, path, Promise }); | ||
@@ -28,5 +32,13 @@ // Perform basic checks on potentially user-defined functions | ||
/*\ | ||
* The hard Promise safety check has been disabled due to the wide variety of Promise libraries out there. | ||
* If you plan to provide your own Promise library, ensure that it can be constructed as a normal Promise and .then works as intended. | ||
\*/ | ||
// if (typeof Reflect.get(this._Promise, 'resolve') !== 'function') { | ||
// throw new Error('Invalid Promise object, "resolve" function property missing!'); | ||
// } | ||
const proxy = this.proxy = new Proxy((arga => { | ||
if (!arga) return this._path.join(this.base, ...this.parts); | ||
return new PathBuilder(this.base, { JSON, path, fs }, [...this.parts, arga.toString()]); | ||
return new PathBuilder(this.base, { JSON, path, fs, Promise }, [...this.parts, arga.toString()]); | ||
}).bind(this), { has: has.bind(this), get: get.bind(this) }); | ||
@@ -33,0 +45,0 @@ return proxy; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19
262
203
21418
1
1