@zenfs/core
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -21,5 +21,6 @@ import type { BFSCallback, FileSystem } from '../filesystem.js'; | ||
* A custom validation function to check if the option is valid. | ||
* Resolves if valid and rejects if not. | ||
* When async, resolves if valid and rejects if not. | ||
* When sync, it will throw an error if not valid. | ||
*/ | ||
validator?(opt: T): Promise<void>; | ||
validator?(opt: T): void | Promise<void>; | ||
} | ||
@@ -26,0 +27,0 @@ /** |
@@ -14,12 +14,2 @@ /// <reference types="node" resolution-mode="require"/> | ||
/** | ||
* Copies a slice of the given buffer | ||
* @internal | ||
*/ | ||
export declare function copyingSlice(buff: Buffer, start?: number, end?: number): Buffer; | ||
/** | ||
* Option validator for a Buffer file system option. | ||
* @internal | ||
*/ | ||
export declare function bufferValidator(v: object): Promise<void>; | ||
/** | ||
* Checks that the given options object is valid for the file system options. | ||
@@ -26,0 +16,0 @@ * @internal |
@@ -23,29 +23,2 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
/** | ||
* Copies a slice of the given buffer | ||
* @internal | ||
*/ | ||
export function copyingSlice(buff, start = 0, end = buff.length) { | ||
if (start < 0 || end < 0 || end > buff.length || start > end) { | ||
throw new TypeError(`Invalid slice bounds on buffer of length ${buff.length}: [${start}, ${end}]`); | ||
} | ||
if (buff.length === 0) { | ||
// Avoid s0 corner case in ArrayBuffer case. | ||
return Buffer.alloc(0); | ||
} | ||
else { | ||
return buff.subarray(start, end); | ||
} | ||
} | ||
/** | ||
* Option validator for a Buffer file system option. | ||
* @internal | ||
*/ | ||
export function bufferValidator(v) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!Buffer.isBuffer(v)) { | ||
throw new ApiError(ErrorCode.EINVAL, 'option must be a Buffer.'); | ||
} | ||
}); | ||
} | ||
/* | ||
@@ -52,0 +25,0 @@ * Levenshtein distance, from the `js-levenshtein` NPM module. |
{ | ||
"name": "@zenfs/core", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "A filesystem in your browser", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1009883
10422