Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

easypathutil

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easypathutil - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

2

package.json
{
"name": "easypathutil",
"version": "1.2.2",
"version": "1.2.3",
"description": "Fluent filepaths, made simple.",

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

@@ -22,3 +22,3 @@ <div align="center">

npm install easypathutil@1.2.2
npm install easypathutil@1.2.3

@@ -35,3 +35,3 @@ ### Two-Part Motivation

• Updated and Lightweight: Package size ~7kB
• Updated and Lightweight: Package size <7.5kB

@@ -191,2 +191,6 @@ The tutorial below aims to demonstrate the core functionality of this package.

## Changelog
### New in 1.2.3
• Fixed several bugs differentiating between sync and async versions of .$ properties. (i.e. file.$stat and file.$stat.sync)
• Fixed async reading of folders
### New in 1.2.2

@@ -193,0 +197,0 @@ • Fixed a bug relating to Promise not being loaded into the ReadHelper, causing async operations to fail

@@ -5,4 +5,4 @@ const regex = exports.regex = /^\$(?:to[._]*)?json$/i;

exports.value = function value() {
const file = this.proxy.$readfilesync.toString();
const file = this.proxy.$readfilesync;
return this._JSON.parse(file);
};

@@ -5,11 +5,14 @@ const regex = exports.regex = /^\$read(?:[._]*)?file(?:[._]*sync)?$/i;

exports.value = function value(object, prop, stringprop) {
if (!this.proxy.$stat.file) throw new Error('Read: I am not a file.');
if (stringprop.includes('sync')) {
if (stringprop.toLowerCase().includes('sync')) {
if (!this.proxy.$statsync.file) throw new Error('Read: I am not a file.');
return this._fs.readFileSync(this.proxy());
} else {
return new this._Promise((res, rej) => this._fs.readFile(this.proxy(), (err, data) => {
if (err) return rej(err);
return res(data);
}));
return Promise.resolve((async() => {
if (!(await this.proxy.$stat).file) throw new Error('Read: I am not a file.');
return new this._Promise((res, rej) => this._fs.readFile(this.proxy(), (err, data) => {
if (err) return rej(err);
return res(data);
}));
})());
}
};

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

const regex = exports.regex = /^\$stat(?:[._]*(?:legacy|number))?$/i;
const regex = exports.regex = /^\$stat([._]*sync)?(?:[._]*(?:legacy|number))?$/i;

@@ -6,3 +6,4 @@ exports.condition = ({ stringprop }) => regex.test(stringprop);

const p = this._path.join(this.base, ...this.parts);
return this.read_dir.get_stat(p, stringprop, this._fs);
if (stringprop.toLowerCase().includes('sync')) return this.read_dir.get_stat_sync(p, stringprop);
return this.read_dir.get_stat(p, stringprop);
};

@@ -15,9 +15,5 @@ /* eslint consistent-return: 0 */

_normalize(sync, filter) {
if (sync === true && !filter) return path => this.get_stat(path).directory;
if (sync === false && !filter) {
return path => new this._Promise((res, rej) => this.fs.stat(path, (err, stat) => {
if (err) return rej(err);
return res(stat);
}));
}
if (sync === true && !filter) return path => this.get_stat_sync(path).directory;
if (sync === false && !filter) return path => this.get_stat(path).then(stat => stat.directory);
let ref = filter || sync;

@@ -82,3 +78,3 @@ if (ref && Object.prototype.toString.call(ref) === '[object String]') return path => path !== ref;

get_stat(path, stringprop = '') {
get_stat_sync(path, stringprop = '') {
try {

@@ -101,2 +97,3 @@ const bigInt = !stringprop.toLowerCase().includes('legacy') && !stringprop.toLowerCase().includes('number');

}
// Throw to bottom catch to re-throw
throw err;

@@ -110,2 +107,41 @@ }

get_stat(path, stringprop = '') {
try {
const bigInt = !stringprop.toLowerCase().includes('legacy') && !stringprop.toLowerCase().includes('number');
return new Promise((res, rej) => this.fs.stat(path, { bigInt }, (err, stat) => {
if (err) {
if (err.code === 'ENOENT') return res(false);
return rej(err);
}
const isDir = stat.isDirectory(),
isFile = stat.isFile(),
isBigInt = typeof stat.size === 'bigint'; // eslint-disable-line valid-typeof
try {
return res({ ...stat,
isBigInt,
isFile, file: isFile,
isDir, folder: isDir,
directory: isDir,
isFolder: isDir,
isDirectory: isDir,
});
} catch (_err) {
if (_err && _err instanceof SyntaxError) {
return res(Object.assign(stat, {
isBigInt,
file: isFile,
folder: isDir,
directory: isDir,
}));
}
return rej(_err);
}
}));
} catch (err) {
if (err && err.code === 'ENOENT') return this._Promise.resolve(false);
return this._Promise.reject(err);
}
}
load_proxy() {

@@ -112,0 +148,0 @@ const list = this.read_recurse_series(this.path.resolve(__dirname, '../deps/traps'));

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