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.0.2 to 1.0.3

2

dist/backends/file_index.d.ts

@@ -45,3 +45,3 @@ import { NoSyncFile } from '../file.js';

}
declare const IndexFS_base: import("../mixins/shared.js").Mixin<typeof FileSystem, {
declare const IndexFS_base: import("../index.js").Mixin<typeof FileSystem, {
metadata(): import("../filesystem.js").FileSystemMetadata;

@@ -48,0 +48,0 @@ rename(oldPath: string, newPath: string): Promise<void>;

@@ -54,3 +54,3 @@ /// <reference types="node" resolution-mode="require"/>

}
declare const PortFS_base: import("../../mixins/shared.js").Mixin<typeof FileSystem, {
declare const PortFS_base: import("../../index.js").Mixin<typeof FileSystem, {
_sync?: FileSystem | undefined;

@@ -57,0 +57,0 @@ queueDone(): Promise<void>;

@@ -13,3 +13,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

export function request(request, { port, timeout = 1000, fs } = {}) {
const stack = new Error().stack.slice('Error:'.length);
const stack = '\n' + new Error().stack.slice('Error:'.length);
if (!port) {

@@ -16,0 +16,0 @@ throw ErrnoError.With('EINVAL');

@@ -26,26 +26,14 @@ import { Stats, type StatsLike } from './stats.js';

export declare class Inode implements StatsLike {
readonly buffer: ArrayBufferLike;
get data(): Uint8Array;
protected view: DataView;
constructor(buffer?: ArrayBufferLike);
get ino(): Ino;
set ino(value: Ino);
get size(): number;
set size(value: number);
get mode(): number;
set mode(value: number);
get nlink(): number;
set nlink(value: number);
get uid(): number;
set uid(value: number);
get gid(): number;
set gid(value: number);
get atimeMs(): number;
set atimeMs(value: number);
get birthtimeMs(): number;
set birthtimeMs(value: number);
get mtimeMs(): number;
set mtimeMs(value: number);
get ctimeMs(): number;
set ctimeMs(value: number);
ino: Ino;
size: number;
mode: number;
nlink: number;
uid: number;
gid: number;
atimeMs: number;
birthtimeMs: number;
mtimeMs: number;
ctimeMs: number;
/**

@@ -52,0 +40,0 @@ * Handy function that converts the Inode to a Node Stats object.

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

var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
var _, done = false;
for (var i = decorators.length - 1; i >= 0; i--) {
var context = {};
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
if (kind === "accessor") {
if (result === void 0) continue;
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
if (_ = accept(result.get)) descriptor.get = _;
if (_ = accept(result.set)) descriptor.set = _;
if (_ = accept(result.init)) initializers.unshift(_);
}
else if (_ = accept(result)) {
if (kind === "field") initializers.unshift(_);
else descriptor[key] = _;
}
}
if (target) Object.defineProperty(target, contextIn.name, descriptor);
done = true;
};
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
var useValue = arguments.length > 2;
for (var i = 0; i < initializers.length; i++) {
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
}
return useValue ? value : void 0;
};
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
};
import { Stats } from './stats.js';
import { types as t, struct, sizeof, serialize, deserialize } from 'utilium';
/**

@@ -26,175 +65,156 @@ * Max 32-bit integer

/**
* Offsets for inode members
*/
const offsets = {
ino: 0,
size: 8,
mode: 12,
nlink: 14,
uid: 18,
gid: 22,
atime: 26,
birthtime: 34,
mtime: 42,
ctime: 50,
end: 58,
};
/**
* Offsets for a 64-bit inode's members
* Currently unused
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const offsets_64 = {
ino: 0,
size: 8,
mode: 16,
nlink: 18,
uid: 22,
gid: 26,
atime: 30,
birthtime: 38,
mtime: 46,
ctime: 54,
end: 62,
};
/**
* Generic inode definition that can easily be serialized.
*/
export class Inode {
get data() {
return new Uint8Array(this.buffer);
}
constructor(buffer) {
const setDefaults = !buffer;
buffer ?? (buffer = new ArrayBuffer(offsets.end));
if (buffer?.byteLength < offsets.end) {
throw new RangeError(`Can not create an inode from a buffer less than ${offsets.end} bytes`);
let Inode = (() => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
let _classDecorators = [struct()];
let _classDescriptor;
let _classExtraInitializers = [];
let _classThis;
let _ino_decorators;
let _ino_initializers = [];
let _ino_extraInitializers = [];
let _size_decorators;
let _size_initializers = [];
let _size_extraInitializers = [];
let _mode_decorators;
let _mode_initializers = [];
let _mode_extraInitializers = [];
let _nlink_decorators;
let _nlink_initializers = [];
let _nlink_extraInitializers = [];
let _uid_decorators;
let _uid_initializers = [];
let _uid_extraInitializers = [];
let _gid_decorators;
let _gid_initializers = [];
let _gid_extraInitializers = [];
let _atimeMs_decorators;
let _atimeMs_initializers = [];
let _atimeMs_extraInitializers = [];
let _birthtimeMs_decorators;
let _birthtimeMs_initializers = [];
let _birthtimeMs_extraInitializers = [];
let _mtimeMs_decorators;
let _mtimeMs_initializers = [];
let _mtimeMs_extraInitializers = [];
let _ctimeMs_decorators;
let _ctimeMs_initializers = [];
let _ctimeMs_extraInitializers = [];
var Inode = _classThis = class {
get data() {
return serialize(this);
}
this.view = new DataView(buffer);
this.buffer = buffer;
if (!setDefaults) {
return;
constructor(buffer) {
this.ino = __runInitializers(this, _ino_initializers, void 0);
this.size = (__runInitializers(this, _ino_extraInitializers), __runInitializers(this, _size_initializers, void 0));
this.mode = (__runInitializers(this, _size_extraInitializers), __runInitializers(this, _mode_initializers, void 0));
this.nlink = (__runInitializers(this, _mode_extraInitializers), __runInitializers(this, _nlink_initializers, void 0));
this.uid = (__runInitializers(this, _nlink_extraInitializers), __runInitializers(this, _uid_initializers, void 0));
this.gid = (__runInitializers(this, _uid_extraInitializers), __runInitializers(this, _gid_initializers, void 0));
this.atimeMs = (__runInitializers(this, _gid_extraInitializers), __runInitializers(this, _atimeMs_initializers, void 0));
this.birthtimeMs = (__runInitializers(this, _atimeMs_extraInitializers), __runInitializers(this, _birthtimeMs_initializers, void 0));
this.mtimeMs = (__runInitializers(this, _birthtimeMs_extraInitializers), __runInitializers(this, _mtimeMs_initializers, void 0));
this.ctimeMs = (__runInitializers(this, _mtimeMs_extraInitializers), __runInitializers(this, _ctimeMs_initializers, void 0));
__runInitializers(this, _ctimeMs_extraInitializers);
if (buffer) {
if (buffer.byteLength < sizeof(Inode)) {
throw new RangeError(`Can not create an inode from a buffer less than ${sizeof(Inode)} bytes`);
}
deserialize(this, buffer);
return;
}
// set defaults on a fresh inode
this.ino = randomIno();
this.nlink = 1;
this.size = 4096;
const now = Date.now();
this.atimeMs = now;
this.mtimeMs = now;
this.ctimeMs = now;
this.birthtimeMs = now;
}
// set defaults on a fresh inode
this.ino = randomIno();
this.nlink = 1;
this.size = 4096;
const now = Date.now();
this.atimeMs = now;
this.mtimeMs = now;
this.ctimeMs = now;
this.birthtimeMs = now;
}
get ino() {
return this.view.getBigUint64(offsets.ino, true);
}
set ino(value) {
this.view.setBigUint64(offsets.ino, value, true);
}
get size() {
return this.view.getUint32(offsets.size, true);
}
set size(value) {
this.view.setUint32(offsets.size, value, true);
}
get mode() {
return this.view.getUint16(offsets.mode, true);
}
set mode(value) {
this.view.setUint16(offsets.mode, value, true);
}
get nlink() {
return this.view.getUint32(offsets.nlink, true);
}
set nlink(value) {
this.view.setUint32(offsets.nlink, value, true);
}
get uid() {
return this.view.getUint32(offsets.uid, true);
}
set uid(value) {
this.view.setUint32(offsets.uid, value, true);
}
get gid() {
return this.view.getUint32(offsets.gid, true);
}
set gid(value) {
this.view.setUint32(offsets.gid, value, true);
}
get atimeMs() {
return this.view.getFloat64(offsets.atime, true);
}
set atimeMs(value) {
this.view.setFloat64(offsets.atime, value, true);
}
get birthtimeMs() {
return this.view.getFloat64(offsets.birthtime, true);
}
set birthtimeMs(value) {
this.view.setFloat64(offsets.birthtime, value, true);
}
get mtimeMs() {
return this.view.getFloat64(offsets.mtime, true);
}
set mtimeMs(value) {
this.view.setFloat64(offsets.mtime, value, true);
}
get ctimeMs() {
return this.view.getFloat64(offsets.ctime, true);
}
set ctimeMs(value) {
this.view.setFloat64(offsets.ctime, value, true);
}
/**
* Handy function that converts the Inode to a Node Stats object.
*/
toStats() {
return new Stats(this);
}
/**
* Updates the Inode using information from the stats object. Used by file
* systems at sync time, e.g.:
* - Program opens file and gets a File object.
* - Program mutates file. File object is responsible for maintaining
* metadata changes locally -- typically in a Stats object.
* - Program closes file. File object's metadata changes are synced with the
* file system.
* @return True if any changes have occurred.
*/
update(stats) {
let hasChanged = false;
if (this.size !== stats.size) {
this.size = stats.size;
hasChanged = true;
/**
* Handy function that converts the Inode to a Node Stats object.
*/
toStats() {
return new Stats(this);
}
if (this.mode !== stats.mode) {
this.mode = stats.mode;
hasChanged = true;
/**
* Updates the Inode using information from the stats object. Used by file
* systems at sync time, e.g.:
* - Program opens file and gets a File object.
* - Program mutates file. File object is responsible for maintaining
* metadata changes locally -- typically in a Stats object.
* - Program closes file. File object's metadata changes are synced with the
* file system.
* @return True if any changes have occurred.
*/
update(stats) {
let hasChanged = false;
if (this.size !== stats.size) {
this.size = stats.size;
hasChanged = true;
}
if (this.mode !== stats.mode) {
this.mode = stats.mode;
hasChanged = true;
}
if (this.nlink !== stats.nlink) {
this.nlink = stats.nlink;
hasChanged = true;
}
if (this.uid !== stats.uid) {
this.uid = stats.uid;
hasChanged = true;
}
if (this.uid !== stats.uid) {
this.uid = stats.uid;
hasChanged = true;
}
if (this.atimeMs !== stats.atimeMs) {
this.atimeMs = stats.atimeMs;
hasChanged = true;
}
if (this.mtimeMs !== stats.mtimeMs) {
this.mtimeMs = stats.mtimeMs;
hasChanged = true;
}
if (this.ctimeMs !== stats.ctimeMs) {
this.ctimeMs = stats.ctimeMs;
hasChanged = true;
}
return hasChanged;
}
if (this.nlink !== stats.nlink) {
this.nlink = stats.nlink;
hasChanged = true;
}
if (this.uid !== stats.uid) {
this.uid = stats.uid;
hasChanged = true;
}
if (this.uid !== stats.uid) {
this.uid = stats.uid;
hasChanged = true;
}
if (this.atimeMs !== stats.atimeMs) {
this.atimeMs = stats.atimeMs;
hasChanged = true;
}
if (this.mtimeMs !== stats.mtimeMs) {
this.mtimeMs = stats.mtimeMs;
hasChanged = true;
}
if (this.ctimeMs !== stats.ctimeMs) {
this.ctimeMs = stats.ctimeMs;
hasChanged = true;
}
return hasChanged;
}
}
};
__setFunctionName(_classThis, "Inode");
(() => {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
_ino_decorators = [(_a = t).uint64.bind(_a)];
_size_decorators = [(_b = t).uint32.bind(_b)];
_mode_decorators = [(_c = t).uint16.bind(_c)];
_nlink_decorators = [(_d = t).uint32.bind(_d)];
_uid_decorators = [(_e = t).uint32.bind(_e)];
_gid_decorators = [(_f = t).uint32.bind(_f)];
_atimeMs_decorators = [(_g = t).float64.bind(_g)];
_birthtimeMs_decorators = [(_h = t).float64.bind(_h)];
_mtimeMs_decorators = [(_j = t).float64.bind(_j)];
_ctimeMs_decorators = [(_k = t).float64.bind(_k)];
__esDecorate(null, null, _ino_decorators, { kind: "field", name: "ino", static: false, private: false, access: { has: obj => "ino" in obj, get: obj => obj.ino, set: (obj, value) => { obj.ino = value; } }, metadata: _metadata }, _ino_initializers, _ino_extraInitializers);
__esDecorate(null, null, _size_decorators, { kind: "field", name: "size", static: false, private: false, access: { has: obj => "size" in obj, get: obj => obj.size, set: (obj, value) => { obj.size = value; } }, metadata: _metadata }, _size_initializers, _size_extraInitializers);
__esDecorate(null, null, _mode_decorators, { kind: "field", name: "mode", static: false, private: false, access: { has: obj => "mode" in obj, get: obj => obj.mode, set: (obj, value) => { obj.mode = value; } }, metadata: _metadata }, _mode_initializers, _mode_extraInitializers);
__esDecorate(null, null, _nlink_decorators, { kind: "field", name: "nlink", static: false, private: false, access: { has: obj => "nlink" in obj, get: obj => obj.nlink, set: (obj, value) => { obj.nlink = value; } }, metadata: _metadata }, _nlink_initializers, _nlink_extraInitializers);
__esDecorate(null, null, _uid_decorators, { kind: "field", name: "uid", static: false, private: false, access: { has: obj => "uid" in obj, get: obj => obj.uid, set: (obj, value) => { obj.uid = value; } }, metadata: _metadata }, _uid_initializers, _uid_extraInitializers);
__esDecorate(null, null, _gid_decorators, { kind: "field", name: "gid", static: false, private: false, access: { has: obj => "gid" in obj, get: obj => obj.gid, set: (obj, value) => { obj.gid = value; } }, metadata: _metadata }, _gid_initializers, _gid_extraInitializers);
__esDecorate(null, null, _atimeMs_decorators, { kind: "field", name: "atimeMs", static: false, private: false, access: { has: obj => "atimeMs" in obj, get: obj => obj.atimeMs, set: (obj, value) => { obj.atimeMs = value; } }, metadata: _metadata }, _atimeMs_initializers, _atimeMs_extraInitializers);
__esDecorate(null, null, _birthtimeMs_decorators, { kind: "field", name: "birthtimeMs", static: false, private: false, access: { has: obj => "birthtimeMs" in obj, get: obj => obj.birthtimeMs, set: (obj, value) => { obj.birthtimeMs = value; } }, metadata: _metadata }, _birthtimeMs_initializers, _birthtimeMs_extraInitializers);
__esDecorate(null, null, _mtimeMs_decorators, { kind: "field", name: "mtimeMs", static: false, private: false, access: { has: obj => "mtimeMs" in obj, get: obj => obj.mtimeMs, set: (obj, value) => { obj.mtimeMs = value; } }, metadata: _metadata }, _mtimeMs_initializers, _mtimeMs_extraInitializers);
__esDecorate(null, null, _ctimeMs_decorators, { kind: "field", name: "ctimeMs", static: false, private: false, access: { has: obj => "ctimeMs" in obj, get: obj => obj.ctimeMs, set: (obj, value) => { obj.ctimeMs = value; } }, metadata: _metadata }, _ctimeMs_initializers, _ctimeMs_extraInitializers);
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
Inode = _classThis = _classDescriptor.value;
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
__runInitializers(_classThis, _classExtraInitializers);
})();
return Inode = _classThis;
})();
export { Inode };
export * from './async.js';
export * from './mutexed.js';
export * from './readonly.js';
export * from './shared.js';
export * from './sync.js';
export * from './async.js';
export * from './mutexed.js';
export * from './readonly.js';
export * from './shared.js';
export * from './sync.js';

@@ -10,5 +10,9 @@ import type { ExtractProperties } from 'utilium';

* Asynchronous `FileSystem` methods. This is a convience type.
* @hidden
*/
export type _AsyncFSMethods = ExtractProperties<FileSystem, (...args: any[]) => Promise<unknown>>;
/**
* Concrete `FileSystem`. This is a convience type.
* @internal
*/
export type _AsyncFSMethods = ExtractProperties<FileSystem, (...args: any[]) => Promise<unknown>>;
export type ConcreteFS = ExtractProperties<FileSystem, any>;
{
"name": "@zenfs/core",
"version": "1.0.2",
"version": "1.0.3",
"description": "A filesystem, anywhere",

@@ -69,3 +69,3 @@ "main": "dist/index.js",

"readable-stream": "^4.5.2",
"utilium": "^0.7.0"
"utilium": "^0.7.2"
},

@@ -72,0 +72,0 @@ "devDependencies": {

@@ -87,3 +87,3 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

): Promise<TValue> {
const stack = new Error().stack!.slice('Error:'.length);
const stack = '\n' + new Error().stack!.slice('Error:'.length);
if (!port) {

@@ -90,0 +90,0 @@ throw ErrnoError.With('EINVAL');

import { Stats, type StatsLike } from './stats.js';
import { types as t, struct, sizeof, serialize, deserialize } from 'utilium';

@@ -37,59 +38,17 @@ /**

/**
* Offsets for inode members
*/
const offsets = {
ino: 0,
size: 8,
mode: 12,
nlink: 14,
uid: 18,
gid: 22,
atime: 26,
birthtime: 34,
mtime: 42,
ctime: 50,
end: 58,
};
/**
* Offsets for a 64-bit inode's members
* Currently unused
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const offsets_64 = {
ino: 0,
size: 8,
mode: 16,
nlink: 18,
uid: 22,
gid: 26,
atime: 30,
birthtime: 38,
mtime: 46,
ctime: 54,
end: 62,
};
/**
* Generic inode definition that can easily be serialized.
*/
@struct()
export class Inode implements StatsLike {
public readonly buffer: ArrayBufferLike;
public get data(): Uint8Array {
return new Uint8Array(this.buffer);
return serialize(this);
}
protected view: DataView;
public constructor(buffer?: ArrayBufferLike) {
const setDefaults = !buffer;
buffer ??= new ArrayBuffer(offsets.end);
if (buffer?.byteLength < offsets.end) {
throw new RangeError(`Can not create an inode from a buffer less than ${offsets.end} bytes`);
}
this.view = new DataView(buffer);
this.buffer = buffer;
if (buffer) {
if (buffer.byteLength < sizeof(Inode)) {
throw new RangeError(`Can not create an inode from a buffer less than ${sizeof(Inode)} bytes`);
}
if (!setDefaults) {
deserialize(this, buffer);
return;

@@ -109,82 +68,13 @@ }

public get ino(): Ino {
return this.view.getBigUint64(offsets.ino, true);
}
@t.uint64 public ino!: Ino;
@t.uint32 public size!: number;
@t.uint16 public mode!: number;
@t.uint32 public nlink!: number;
@t.uint32 public uid!: number;
@t.uint32 public gid!: number;
@t.float64 public atimeMs!: number;
@t.float64 public birthtimeMs!: number;
@t.float64 public mtimeMs!: number;
@t.float64 public ctimeMs!: number;
public set ino(value: Ino) {
this.view.setBigUint64(offsets.ino, value, true);
}
public get size(): number {
return this.view.getUint32(offsets.size, true);
}
public set size(value: number) {
this.view.setUint32(offsets.size, value, true);
}
public get mode(): number {
return this.view.getUint16(offsets.mode, true);
}
public set mode(value: number) {
this.view.setUint16(offsets.mode, value, true);
}
public get nlink(): number {
return this.view.getUint32(offsets.nlink, true);
}
public set nlink(value: number) {
this.view.setUint32(offsets.nlink, value, true);
}
public get uid(): number {
return this.view.getUint32(offsets.uid, true);
}
public set uid(value: number) {
this.view.setUint32(offsets.uid, value, true);
}
public get gid(): number {
return this.view.getUint32(offsets.gid, true);
}
public set gid(value: number) {
this.view.setUint32(offsets.gid, value, true);
}
public get atimeMs(): number {
return this.view.getFloat64(offsets.atime, true);
}
public set atimeMs(value: number) {
this.view.setFloat64(offsets.atime, value, true);
}
public get birthtimeMs(): number {
return this.view.getFloat64(offsets.birthtime, true);
}
public set birthtimeMs(value: number) {
this.view.setFloat64(offsets.birthtime, value, true);
}
public get mtimeMs(): number {
return this.view.getFloat64(offsets.mtime, true);
}
public set mtimeMs(value: number) {
this.view.setFloat64(offsets.mtime, value, true);
}
public get ctimeMs(): number {
return this.view.getFloat64(offsets.ctime, true);
}
public set ctimeMs(value: number) {
this.view.setFloat64(offsets.ctime, value, true);
}
/**

@@ -191,0 +81,0 @@ * Handy function that converts the Inode to a Node Stats object.

export * from './async.js';
export * from './mutexed.js';
export * from './readonly.js';
export * from './shared.js';
export * from './sync.js';

@@ -17,6 +17,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

* Asynchronous `FileSystem` methods. This is a convience type.
* @internal
* @hidden
*/
export type _AsyncFSMethods = ExtractProperties<FileSystem, (...args: any[]) => Promise<unknown>>;
/**
* Concrete `FileSystem`. This is a convience type.
* @internal
*/
export type ConcreteFS = ExtractProperties<FileSystem, any>;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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