@zenfs/core
Advanced tools
Comparing version 1.4.2 to 1.4.3
@@ -29,8 +29,12 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { | ||
} | ||
var r, s = 0; | ||
function next() { | ||
while (env.stack.length) { | ||
var rec = env.stack.pop(); | ||
while (r = env.stack.pop()) { | ||
try { | ||
var result = rec.dispose && rec.dispose.call(rec.value); | ||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); | ||
if (r.dispose) { | ||
var result = r.dispose.call(r.value); | ||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
} | ||
else s |= 1; | ||
} | ||
@@ -41,2 +45,3 @@ catch (e) { | ||
} | ||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); | ||
if (env.hasError) throw env.error; | ||
@@ -43,0 +48,0 @@ } |
@@ -29,8 +29,12 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { | ||
} | ||
var r, s = 0; | ||
function next() { | ||
while (env.stack.length) { | ||
var rec = env.stack.pop(); | ||
while (r = env.stack.pop()) { | ||
try { | ||
var result = rec.dispose && rec.dispose.call(rec.value); | ||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); | ||
if (r.dispose) { | ||
var result = r.dispose.call(r.value); | ||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
} | ||
else s |= 1; | ||
} | ||
@@ -41,2 +45,3 @@ catch (e) { | ||
} | ||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); | ||
if (env.hasError) throw env.error; | ||
@@ -43,0 +48,0 @@ } |
@@ -32,8 +32,12 @@ /* | ||
} | ||
var r, s = 0; | ||
function next() { | ||
while (env.stack.length) { | ||
var rec = env.stack.pop(); | ||
while (r = env.stack.pop()) { | ||
try { | ||
var result = rec.dispose && rec.dispose.call(rec.value); | ||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); | ||
if (r.dispose) { | ||
var result = r.dispose.call(r.value); | ||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
} | ||
else s |= 1; | ||
} | ||
@@ -44,2 +48,3 @@ catch (e) { | ||
} | ||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); | ||
if (env.hasError) throw env.error; | ||
@@ -46,0 +51,0 @@ } |
@@ -29,8 +29,12 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { | ||
} | ||
var r, s = 0; | ||
function next() { | ||
while (env.stack.length) { | ||
var rec = env.stack.pop(); | ||
while (r = env.stack.pop()) { | ||
try { | ||
var result = rec.dispose && rec.dispose.call(rec.value); | ||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); | ||
if (r.dispose) { | ||
var result = r.dispose.call(r.value); | ||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
} | ||
else s |= 1; | ||
} | ||
@@ -41,2 +45,3 @@ catch (e) { | ||
} | ||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); | ||
if (env.hasError) throw env.error; | ||
@@ -536,5 +541,5 @@ } | ||
const handle = __addDisposableResource(env_3, path instanceof FileHandle ? path : await open.call(this, path.toString(), options.flag, options.mode), true); | ||
const _data = typeof data == 'string' ? data : data; | ||
const _data = typeof data == 'string' ? data : data instanceof DataView ? new Uint8Array(data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)) : data; | ||
if (typeof _data != 'string' && !(_data instanceof Uint8Array)) { | ||
throw new ErrnoError(Errno.EINVAL, 'Iterables and streams not supported', handle.file.path, 'writeFile'); | ||
throw new ErrnoError(Errno.EINVAL, 'The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received ' + typeof data, handle.file.path, 'writeFile'); | ||
} | ||
@@ -541,0 +546,0 @@ await handle.writeFile(_data, options); |
@@ -78,3 +78,3 @@ // Utilities and shared data | ||
// We know path is normalized, so it would be a substring of the mount point. | ||
if (mountPoint.length <= path.length && path.startsWith(mountPoint)) { | ||
if (_isParentOf(mountPoint, path)) { | ||
path = path.slice(mountPoint.length > 1 ? mountPoint.length : 0); // Resolve the path relative to the mount point | ||
@@ -164,1 +164,11 @@ if (path === '') { | ||
} | ||
/** | ||
* @internal @hidden | ||
*/ | ||
function _isParentOf(parent, child) { | ||
if (parent === '/' || parent === child) | ||
return true; | ||
if (!parent.endsWith('/')) | ||
parent += '/'; | ||
return child.startsWith(parent); | ||
} |
@@ -29,8 +29,12 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { | ||
} | ||
var r, s = 0; | ||
function next() { | ||
while (env.stack.length) { | ||
var rec = env.stack.pop(); | ||
while (r = env.stack.pop()) { | ||
try { | ||
var result = rec.dispose && rec.dispose.call(rec.value); | ||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); | ||
if (r.dispose) { | ||
var result = r.dispose.call(r.value); | ||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
} | ||
else s |= 1; | ||
} | ||
@@ -41,2 +45,3 @@ catch (e) { | ||
} | ||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); | ||
if (env.hasError) throw env.error; | ||
@@ -43,0 +48,0 @@ } |
@@ -5,24 +5,2 @@ import type { FileReadResult } from 'node:fs/promises'; | ||
import { Stats } from './stats.js'; | ||
/** | ||
Typescript does not include a type declaration for resizable array buffers. | ||
It has been standardized into ECMAScript though | ||
@todo Remove this if TS adds them to lib declarations | ||
*/ | ||
declare global { | ||
interface ArrayBuffer { | ||
readonly resizable: boolean; | ||
readonly maxByteLength?: number; | ||
resize(newLength: number): void; | ||
} | ||
interface SharedArrayBuffer { | ||
readonly resizable: boolean; | ||
readonly maxByteLength?: number; | ||
resize(newLength: number): void; | ||
} | ||
interface ArrayBufferConstructor { | ||
new (byteLength: number, options: { | ||
maxByteLength?: number; | ||
}): ArrayBuffer; | ||
} | ||
} | ||
export declare function parseFlag(flag: string | number): string; | ||
@@ -29,0 +7,0 @@ export declare function flagToString(flag: number): string; |
@@ -307,5 +307,9 @@ import { config } from './emulation/config.js'; | ||
if (end > this._buffer.byteLength) { | ||
if (this._buffer.buffer.resizable && this._buffer.buffer.maxByteLength <= end) { | ||
this._buffer.buffer.resize(end); | ||
const { buffer } = this._buffer; | ||
if ('resizable' in buffer && buffer.resizable && buffer.maxByteLength <= end) { | ||
buffer.resize(end); | ||
} | ||
else if ('growable' in buffer && buffer.growable && buffer.maxByteLength <= end) { | ||
buffer.grow(end); | ||
} | ||
else if (config.unsafeBufferReplace) { | ||
@@ -312,0 +316,0 @@ this._buffer = slice; |
@@ -29,8 +29,12 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { | ||
} | ||
var r, s = 0; | ||
function next() { | ||
while (env.stack.length) { | ||
var rec = env.stack.pop(); | ||
while (r = env.stack.pop()) { | ||
try { | ||
var result = rec.dispose && rec.dispose.call(rec.value); | ||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); | ||
if (r.dispose) { | ||
var result = r.dispose.call(r.value); | ||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
} | ||
else s |= 1; | ||
} | ||
@@ -41,2 +45,3 @@ catch (e) { | ||
} | ||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); | ||
if (env.hasError) throw env.error; | ||
@@ -43,0 +48,0 @@ } |
@@ -29,8 +29,12 @@ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { | ||
} | ||
var r, s = 0; | ||
function next() { | ||
while (env.stack.length) { | ||
var rec = env.stack.pop(); | ||
while (r = env.stack.pop()) { | ||
try { | ||
var result = rec.dispose && rec.dispose.call(rec.value); | ||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next); | ||
if (r.dispose) { | ||
var result = r.dispose.call(r.value); | ||
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
} | ||
else s |= 1; | ||
} | ||
@@ -41,2 +45,3 @@ catch (e) { | ||
} | ||
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve(); | ||
if (env.hasError) throw env.error; | ||
@@ -43,0 +48,0 @@ } |
{ | ||
"name": "@zenfs/core", | ||
"version": "1.4.2", | ||
"version": "1.4.3", | ||
"description": "A filesystem, anywhere", | ||
@@ -75,3 +75,3 @@ "funding": { | ||
"readable-stream": "^4.5.2", | ||
"utilium": "^1.0.0" | ||
"utilium": "^1.1.1" | ||
}, | ||
@@ -85,3 +85,3 @@ "optionalDependencies": { | ||
"c8": "^10.1.2", | ||
"eslint": "^9.8.0", | ||
"eslint": "^9.15.0", | ||
"globals": "^15.9.0", | ||
@@ -91,7 +91,7 @@ "lint-staged": "^15.2.7", | ||
"tsx": "^4.19.1", | ||
"typedoc": "^0.26.10", | ||
"typedoc": "^0.27.1", | ||
"typedoc-plugin-remove-references": "^0.0.6", | ||
"typescript": "^5.5.0", | ||
"typescript-eslint": "^8.0.0" | ||
"typescript": "^5.7.2", | ||
"typescript-eslint": "^8.16.0" | ||
} | ||
} |
578518
14663
Updatedutilium@^1.1.1