@file-services/memory
Advanced tools
Comparing version
@@ -246,15 +246,29 @@ "use strict"; | ||
} | ||
function statSync(nodePath) { | ||
function statSync(nodePath, options) { | ||
var _a; | ||
const resolvedPath = resolvePath(nodePath); | ||
const node = getNode(resolvedPath); | ||
if (!node) { | ||
throw createFsError(resolvedPath, error_codes_js_1.FsErrorCodes.NO_FILE_OR_DIRECTORY, 'ENOENT'); | ||
const throwIfNoEntry = (_a = options === null || options === void 0 ? void 0 : options.throwIfNoEntry) !== null && _a !== void 0 ? _a : true; | ||
if (throwIfNoEntry) { | ||
throw createFsError(resolvedPath, error_codes_js_1.FsErrorCodes.NO_FILE_OR_DIRECTORY, 'ENOENT'); | ||
} | ||
else { | ||
return undefined; | ||
} | ||
} | ||
return node.entry; | ||
} | ||
function lstatSync(nodePath) { | ||
function lstatSync(nodePath, options) { | ||
var _a; | ||
const resolvedPath = resolvePath(nodePath); | ||
const node = getRawNode(resolvedPath); | ||
if (!node) { | ||
throw createFsError(resolvedPath, error_codes_js_1.FsErrorCodes.NO_FILE_OR_DIRECTORY, 'ENOENT'); | ||
const throwIfNoEntry = (_a = options === null || options === void 0 ? void 0 : options.throwIfNoEntry) !== null && _a !== void 0 ? _a : true; | ||
if (throwIfNoEntry) { | ||
throw createFsError(resolvedPath, error_codes_js_1.FsErrorCodes.NO_FILE_OR_DIRECTORY, 'ENOENT'); | ||
} | ||
else { | ||
return undefined; | ||
} | ||
} | ||
@@ -261,0 +275,0 @@ return node.entry; |
{ | ||
"name": "@file-services/memory", | ||
"description": "An in-memory, sync/async, file system implementation.", | ||
"version": "5.4.1", | ||
"version": "5.7.0", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"test": "yarn test:node && yarn test:browser", | ||
"test": "npm run test:node && npm run test:browser", | ||
"test:node": "mocha \"./dist/test/*.{spec,nodespec}.js\"", | ||
@@ -12,5 +12,5 @@ "test:browser": "mocha-play \"./dist/test/**/*.spec.js\"" | ||
"dependencies": { | ||
"@file-services/path": "^5.4.1", | ||
"@file-services/types": "^5.4.0", | ||
"@file-services/utils": "^5.4.0" | ||
"@file-services/path": "^5.7.0", | ||
"@file-services/types": "^5.7.0", | ||
"@file-services/utils": "^5.7.0" | ||
}, | ||
@@ -17,0 +17,0 @@ "files": [ |
@@ -22,3 +22,3 @@ # @file-services/memory | ||
```sh | ||
yarn add @file-services/memory | ||
npm i @file-services/memory | ||
``` | ||
@@ -25,0 +25,0 @@ |
@@ -12,2 +12,3 @@ import { createFileSystem, syncToAsyncFs, SetMultiMap } from '@file-services/utils'; | ||
IBaseFileSystemSyncActions, | ||
StatSyncOptions, | ||
} from '@file-services/types'; | ||
@@ -296,7 +297,17 @@ import { FsErrorCodes } from './error-codes.js'; | ||
function statSync(nodePath: string): IFileSystemStats { | ||
function statSync(nodePath: string, options?: StatSyncOptions & { throwIfNoEntry?: true }): IFileSystemStats; | ||
function statSync( | ||
nodePath: string, | ||
options: StatSyncOptions & { throwIfNoEntry: false } | ||
): IFileSystemStats | undefined; | ||
function statSync(nodePath: string, options?: StatSyncOptions): IFileSystemStats | undefined { | ||
const resolvedPath = resolvePath(nodePath); | ||
const node = getNode(resolvedPath); | ||
if (!node) { | ||
throw createFsError(resolvedPath, FsErrorCodes.NO_FILE_OR_DIRECTORY, 'ENOENT'); | ||
const throwIfNoEntry = options?.throwIfNoEntry ?? true; | ||
if (throwIfNoEntry) { | ||
throw createFsError(resolvedPath, FsErrorCodes.NO_FILE_OR_DIRECTORY, 'ENOENT'); | ||
} else { | ||
return undefined; | ||
} | ||
} | ||
@@ -306,7 +317,17 @@ return node.entry; | ||
function lstatSync(nodePath: string): IFileSystemStats { | ||
function lstatSync(nodePath: string, options?: StatSyncOptions & { throwIfNoEntry?: true }): IFileSystemStats; | ||
function lstatSync( | ||
nodePath: string, | ||
options: StatSyncOptions & { throwIfNoEntry: false } | ||
): IFileSystemStats | undefined; | ||
function lstatSync(nodePath: string, options?: StatSyncOptions): IFileSystemStats | undefined { | ||
const resolvedPath = resolvePath(nodePath); | ||
const node = getRawNode(resolvedPath); | ||
if (!node) { | ||
throw createFsError(resolvedPath, FsErrorCodes.NO_FILE_OR_DIRECTORY, 'ENOENT'); | ||
const throwIfNoEntry = options?.throwIfNoEntry ?? true; | ||
if (throwIfNoEntry) { | ||
throw createFsError(resolvedPath, FsErrorCodes.NO_FILE_OR_DIRECTORY, 'ENOENT'); | ||
} else { | ||
return undefined; | ||
} | ||
} | ||
@@ -313,0 +334,0 @@ return node.entry; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
66324
2.75%1124
3.21%Updated
Updated
Updated