New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@zenfs/core

Package Overview
Dependencies
Maintainers
0
Versions
165
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zenfs/core - npm Package Compare versions

Comparing version 1.2.4 to 1.2.5

4

dist/emulation/config.d.ts

@@ -10,2 +10,6 @@ export declare const config: {

updateOnRead: boolean;
/**
* If a file's buffer is not large enough to store content when writing and the buffer can't be resized, reuse the buffer passed to write()
*/
unsafeBufferReplace: boolean;
};

@@ -10,2 +10,6 @@ export const config = {

updateOnRead: true,
/**
* If a file's buffer is not large enough to store content when writing and the buffer can't be resized, reuse the buffer passed to write()
*/
unsafeBufferReplace: false,
};

97

dist/emulation/promises.js

@@ -488,3 +488,2 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {

await handle.truncate(0);
await handle.sync();
}

@@ -742,20 +741,13 @@ return handle;

export async function symlink(target, path, type = 'file') {
if (!['file', 'dir', 'junction'].includes(type)) {
throw new ErrnoError(Errno.EINVAL, 'Invalid symlink type: ' + type);
}
if (await exists(path)) {
throw ErrnoError.With('EEXIST', path.toString(), 'symlink');
}
await writeFile(path, target.toString());
const handle = await _open(path, 'r+', 0o644, false);
await handle.file._setType(constants.S_IFLNK);
}
symlink;
export async function readlink(path, options) {
const env_5 = { stack: [], error: void 0, hasError: false };
try {
const handle = __addDisposableResource(env_5, await _open(normalizePath(path), 'r', 0o644, false), true);
const value = await handle.readFile();
const encoding = typeof options == 'object' ? options?.encoding : options;
return encoding == 'buffer' ? value : value.toString(encoding);
if (!['file', 'dir', 'junction'].includes(type)) {
throw new ErrnoError(Errno.EINVAL, 'Invalid symlink type: ' + type);
}
if (await exists(path)) {
throw ErrnoError.With('EEXIST', path.toString(), 'symlink');
}
const handle = __addDisposableResource(env_5, await _open(path, 'w+', 0o644, false), true);
await handle.writeFile(target.toString());
await handle.file._setType(constants.S_IFLNK);
}

@@ -772,9 +764,10 @@ catch (e_5) {

}
readlink;
// PROPERTY OPERATIONS
export async function chown(path, uid, gid) {
symlink;
export async function readlink(path, options) {
const env_6 = { stack: [], error: void 0, hasError: false };
try {
const handle = __addDisposableResource(env_6, await open(path, 'r+'), true);
await handle.chown(uid, gid);
const handle = __addDisposableResource(env_6, await _open(normalizePath(path), 'r', 0o644, false), true);
const value = await handle.readFile();
const encoding = typeof options == 'object' ? options?.encoding : options;
return encoding == 'buffer' ? value : value.toString(encoding);
}

@@ -791,7 +784,8 @@ catch (e_6) {

}
chown;
export async function lchown(path, uid, gid) {
readlink;
// PROPERTY OPERATIONS
export async function chown(path, uid, gid) {
const env_7 = { stack: [], error: void 0, hasError: false };
try {
const handle = __addDisposableResource(env_7, await _open(path, 'r+', 0o644, false), true);
const handle = __addDisposableResource(env_7, await open(path, 'r+'), true);
await handle.chown(uid, gid);

@@ -809,8 +803,8 @@ }

}
lchown;
export async function chmod(path, mode) {
chown;
export async function lchown(path, uid, gid) {
const env_8 = { stack: [], error: void 0, hasError: false };
try {
const handle = __addDisposableResource(env_8, await open(path, 'r+'), true);
await handle.chmod(mode);
const handle = __addDisposableResource(env_8, await _open(path, 'r+', 0o644, false), true);
await handle.chown(uid, gid);
}

@@ -827,7 +821,7 @@ catch (e_8) {

}
chmod;
export async function lchmod(path, mode) {
lchown;
export async function chmod(path, mode) {
const env_9 = { stack: [], error: void 0, hasError: false };
try {
const handle = __addDisposableResource(env_9, await _open(path, 'r+', 0o644, false), true);
const handle = __addDisposableResource(env_9, await open(path, 'r+'), true);
await handle.chmod(mode);

@@ -845,11 +839,8 @@ }

}
lchmod;
/**
* Change file timestamps of the file referenced by the supplied path.
*/
export async function utimes(path, atime, mtime) {
chmod;
export async function lchmod(path, mode) {
const env_10 = { stack: [], error: void 0, hasError: false };
try {
const handle = __addDisposableResource(env_10, await open(path, 'r+'), true);
await handle.utimes(atime, mtime);
const handle = __addDisposableResource(env_10, await _open(path, 'r+', 0o644, false), true);
await handle.chmod(mode);
}

@@ -866,11 +857,11 @@ catch (e_10) {

}
utimes;
lchmod;
/**
* Change file timestamps of the file referenced by the supplied path.
*/
export async function lutimes(path, atime, mtime) {
export async function utimes(path, atime, mtime) {
const env_11 = { stack: [], error: void 0, hasError: false };
try {
const handle = __addDisposableResource(env_11, await _open(path, 'r+', 0o644, false), true);
await handle.utimes(new Date(atime), new Date(mtime));
const handle = __addDisposableResource(env_11, await open(path, 'r+'), true);
await handle.utimes(atime, mtime);
}

@@ -887,2 +878,22 @@ catch (e_11) {

}
utimes;
/**
* Change file timestamps of the file referenced by the supplied path.
*/
export async function lutimes(path, atime, mtime) {
const env_12 = { stack: [], error: void 0, hasError: false };
try {
const handle = __addDisposableResource(env_12, await _open(path, 'r+', 0o644, false), true);
await handle.utimes(new Date(atime), new Date(mtime));
}
catch (e_12) {
env_12.error = e_12;
env_12.hasError = true;
}
finally {
const result_12 = __disposeResources(env_12);
if (result_12)
await result_12;
}
}
lutimes;

@@ -889,0 +900,0 @@ export async function realpath(path, options) {

@@ -196,3 +196,2 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {

file.truncateSync(0);
file.syncSync();
}

@@ -199,0 +198,0 @@ return file;

@@ -302,7 +302,8 @@ import { O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_SYNC, O_TRUNC, O_WRONLY, S_IFMT, size_max } from './emulation/constants.js';

}
this.dirty = true;
if (!isWriteable(this.flag)) {
throw new ErrnoError(Errno.EPERM, 'File not opened with a writeable mode.');
}
this.dirty = true;
const end = position + length;
const slice = buffer.slice(offset, offset + length);
if (end > this.stats.size) {

@@ -314,2 +315,5 @@ this.stats.size = end;

}
else if (config.unsafeBufferReplace) {
this._buffer = slice;
}
else {

@@ -323,3 +327,2 @@ // Extend the buffer!

}
const slice = buffer.slice(offset, offset + length);
this._buffer.set(slice, position);

@@ -376,3 +379,3 @@ this.stats.mtimeMs = Date.now();

if (bytesRead == 0) {
// No copy/read. Return immediatly for better performance
// No copy/read. Return immediately for better performance
return bytesRead;

@@ -379,0 +382,0 @@ }

{
"name": "@zenfs/core",
"version": "1.2.4",
"version": "1.2.5",
"description": "A filesystem, anywhere",

@@ -5,0 +5,0 @@ "funding": {

@@ -11,2 +11,7 @@ export const config = {

updateOnRead: true,
/**
* If a file's buffer is not large enough to store content when writing and the buffer can't be resized, reuse the buffer passed to write()
*/
unsafeBufferReplace: false,
};

@@ -532,3 +532,2 @@ /* eslint-disable @typescript-eslint/no-redundant-type-constituents */

await handle.truncate(0);
await handle.sync();
}

@@ -836,4 +835,4 @@

await writeFile(path, target.toString());
const handle = await _open(path, 'r+', 0o644, false);
await using handle = await _open(path, 'w+', 0o644, false);
await handle.writeFile(target.toString());
await handle.file._setType(constants.S_IFLNK);

@@ -840,0 +839,0 @@ }

@@ -162,3 +162,2 @@ import { Buffer } from 'buffer';

file.truncateSync(0);
file.syncSync();
}

@@ -165,0 +164,0 @@

@@ -456,7 +456,10 @@ import type { FileReadResult } from 'node:fs/promises';

}
this.dirty = true;
if (!isWriteable(this.flag)) {
throw new ErrnoError(Errno.EPERM, 'File not opened with a writeable mode.');
}
this.dirty = true;
const end = position + length;
const slice = buffer.slice(offset, offset + length);

@@ -468,2 +471,4 @@ if (end > this.stats.size) {

this._buffer.buffer.resize(end);
} else if (config.unsafeBufferReplace) {
this._buffer = slice;
} else {

@@ -477,3 +482,3 @@ // Extend the buffer!

}
const slice = buffer.slice(offset, offset + length);
this._buffer.set(slice, position);

@@ -533,3 +538,3 @@ this.stats.mtimeMs = Date.now();

if (bytesRead == 0) {
// No copy/read. Return immediatly for better performance
// No copy/read. Return immediately for better performance
return bytesRead;

@@ -536,0 +541,0 @@ }

@@ -7,28 +7,25 @@ import assert from 'node:assert';

const syncMode = 0o644;
const file = 'a.js';
suite('chmod tests', () => {
test('chmod', async () => {
const file1 = 'a.js';
await fs.promises.chmod(file, asyncMode.toString(8));
await fs.promises.chmod(file1, asyncMode.toString(8));
const stats = await fs.promises.stat(file);
assert.equal(stats.mode & 0o777, asyncMode);
const stats = await fs.promises.stat(file1);
assert((stats.mode & 0o777) === asyncMode);
fs.chmodSync(file1, syncMode);
assert((fs.statSync(file1).mode & 0o777) === syncMode);
fs.chmodSync(file, syncMode);
assert.equal(fs.statSync(file).mode & 0o777, syncMode);
});
test('fchmod', async () => {
const file2 = 'a1.js';
const handle = await fs.promises.open(file, 'a', 0o644);
const handle = await fs.promises.open(file2, 'a', 0o644);
await handle.chmod(asyncMode);
const stats = await handle.stat();
assert((stats.mode & 0o777) === asyncMode);
assert.equal(stats.mode & 0o777, asyncMode);
fs.fchmodSync(handle.fd, syncMode);
assert((fs.statSync(file2).mode & 0o777) === syncMode);
assert.equal(fs.statSync(file).mode & 0o777, syncMode);
});

@@ -38,13 +35,12 @@

const link = 'symbolic-link';
const target = 'a1.js';
await fs.promises.symlink(target, link);
await fs.promises.symlink(file, link);
await fs.promises.lchmod(link, asyncMode);
const stats = await fs.promises.lstat(link);
assert((stats.mode & 0o777) === asyncMode);
assert.equal(stats.mode & 0o777, asyncMode);
fs.lchmodSync(link, syncMode);
assert((fs.lstatSync(link).mode & 0o777) === syncMode);
assert.equal(fs.lstatSync(link).mode & 0o777, syncMode);
});
});

@@ -13,3 +13,3 @@ import assert from 'node:assert';

fs.writeFileSync(path, data);
assert(fs.statSync(path).size === size);
assert.equal(fs.statSync(path).size, size);
});

@@ -19,3 +19,3 @@

fs.truncateSync(path, 1024);
assert(fs.statSync(path).size === 1024);
assert.equal(fs.statSync(path).size, 1024);
});

@@ -25,3 +25,3 @@

fs.truncateSync(path);
assert(fs.statSync(path).size === 0);
assert.equal(fs.statSync(path).size, 0);
});

@@ -31,3 +31,3 @@

fs.writeFileSync(path, data);
assert(fs.statSync(path).size === size);
assert.equal(fs.statSync(path).size, size);
});

@@ -42,3 +42,3 @@

fs.ftruncateSync(fd, 1024);
assert(fs.fstatSync(fd).size === 1024);
assert.equal(fs.fstatSync(fd).size, 1024);
});

@@ -48,3 +48,3 @@

fs.ftruncateSync(fd);
assert(fs.fstatSync(fd).size === 0);
assert.equal(fs.fstatSync(fd).size, 0);
});

@@ -62,3 +62,3 @@

assert((await statSize(path)) === 1024 * 16);
assert.equal(await statSize(path), 1024 * 16);
});

@@ -68,3 +68,3 @@

await fs.promises.truncate(path, 1024);
assert((await statSize(path)) === 1024);
assert.equal(await statSize(path), 1024);
});

@@ -74,3 +74,3 @@

await fs.promises.truncate(path);
assert((await statSize(path)) === 0);
assert.equal(await statSize(path), 0);
});

@@ -80,3 +80,3 @@

await fs.promises.writeFile(path, data);
assert((await statSize(path)) === size);
assert.equal(await statSize(path), size);
});

@@ -92,3 +92,3 @@

await handle.sync();
assert((await statSize(path)) === 1024);
assert.equal(await statSize(path), 1024);
});

@@ -99,3 +99,3 @@

await handle.sync();
assert((await statSize(path)) === 0);
assert.equal(await statSize(path), 0);
});

@@ -102,0 +102,0 @@

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