package/LICENSE000664 0000002067 3560116604 010274 0ustar00000000 000000 The MIT License (MIT) Copyright (c) Denis Malinochkin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package/out/dirent.js000664 0000002270 3560116604 011715 0ustar00000000 000000 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class Dirent { constructor(_options = {}) { var _a; this._options = _options; this.name = (_a = this._options.name) !== null && _a !== void 0 ? _a : 'unknown.txt'; } isFile() { var _a; return (_a = this._options.isFile) !== null && _a !== void 0 ? _a : true; } isDirectory() { var _a; return (_a = this._options.isDirectory) !== null && _a !== void 0 ? _a : false; } isBlockDevice() { var _a; return (_a = this._options.isBlockDevice) !== null && _a !== void 0 ? _a : false; } isCharacterDevice() { var _a; return (_a = this._options.isCharacterDevice) !== null && _a !== void 0 ? _a : false; } isSymbolicLink() { var _a; return (_a = this._options.isSymbolicLink) !== null && _a !== void 0 ? _a : false; } isFIFO() { var _a; return (_a = this._options.isFIFO) !== null && _a !== void 0 ? _a : false; } isSocket() { var _a; return (_a = this._options.isSocket) !== null && _a !== void 0 ? _a : false; } } exports.default = Dirent; package/out/index.js000664 0000000404 3560116604 011534 0ustar00000000 000000 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Stats = exports.Dirent = void 0; const dirent_1 = require("./dirent"); exports.Dirent = dirent_1.default; const stats_1 = require("./stats"); exports.Stats = stats_1.default; package/out/stats.js000664 0000005635 3560116604 011576 0ustar00000000 000000 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const uid = process.platform === 'win32' ? undefined : process.getuid(); const gid = process.platform === 'win32' ? undefined : process.getgid(); class Stats { constructor(_options = {}) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; this._options = _options; this._date = new Date(); this.dev = (_a = this._options.dev) !== null && _a !== void 0 ? _a : 0; this.ino = (_b = this._options.ino) !== null && _b !== void 0 ? _b : 0; this.mode = (_c = this._options.mode) !== null && _c !== void 0 ? _c : 0; this.nlink = (_d = this._options.nlink) !== null && _d !== void 0 ? _d : 0; this.uid = ('uid' in this._options ? this._options.uid : uid); this.gid = ('gid' in this._options ? this._options.gid : gid); this.rdev = (_e = this._options.rdev) !== null && _e !== void 0 ? _e : 0; this.size = (_f = this._options.size) !== null && _f !== void 0 ? _f : 0; this.blksize = (_g = this._options.blksize) !== null && _g !== void 0 ? _g : 0; this.blocks = (_h = this._options.blocks) !== null && _h !== void 0 ? _h : 0; this.atimeMs = (_j = this._options.atimeMs) !== null && _j !== void 0 ? _j : this._date.getTime(); this.mtimeMs = (_k = this._options.mtimeMs) !== null && _k !== void 0 ? _k : this._date.getTime(); this.ctimeMs = (_l = this._options.ctimeMs) !== null && _l !== void 0 ? _l : this._date.getTime(); this.birthtimeMs = (_m = this._options.birthtimeMs) !== null && _m !== void 0 ? _m : this._date.getTime(); this.atime = (_o = this._options.atime) !== null && _o !== void 0 ? _o : this._date; this.mtime = (_p = this._options.mtime) !== null && _p !== void 0 ? _p : this._date; this.ctime = (_q = this._options.ctime) !== null && _q !== void 0 ? _q : this._date; this.birthtime = (_r = this._options.birthtime) !== null && _r !== void 0 ? _r : this._date; } isFile() { var _a; return (_a = this._options.isFile) !== null && _a !== void 0 ? _a : true; } isDirectory() { var _a; return (_a = this._options.isDirectory) !== null && _a !== void 0 ? _a : false; } isBlockDevice() { var _a; return (_a = this._options.isBlockDevice) !== null && _a !== void 0 ? _a : false; } isCharacterDevice() { var _a; return (_a = this._options.isCharacterDevice) !== null && _a !== void 0 ? _a : false; } isSymbolicLink() { var _a; return (_a = this._options.isSymbolicLink) !== null && _a !== void 0 ? _a : false; } isFIFO() { var _a; return (_a = this._options.isFIFO) !== null && _a !== void 0 ? _a : false; } isSocket() { var _a; return (_a = this._options.isSocket) !== null && _a !== void 0 ? _a : false; } } exports.default = Stats; package/out/types.js000664 0000000115 3560116604 011570 0ustar00000000 000000 "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); package/package.json000664 0000001712 3560116604 011551 0ustar00000000 000000 { "name": "@nodelib/fs.macchiato", "version": "1.0.4", "description": "A set of classes for easy testing of built-in structures of FS", "license": "MIT", "repository": "https://github.com/nodelib/nodelib/tree/master/packages/fs/fs.macchiato", "keywords": [ "NodeLib", "fs", "FileSystem", "file system", "mock", "stat", "dirent" ], "engines": { "node": ">= 8" }, "files": [ "out/*", "!out/*.map", "!out/*.spec.*" ], "main": "out/index.js", "typings": "out/index.d.ts", "scripts": { "clean": "rimraf {tsconfig.tsbuildinfo,out}", "lint": "eslint \"src/**/*.ts\" --cache", "compile": "tsc -b .", "compile:watch": "tsc -p . --watch --sourceMap", "test": "mocha \"out/**/*.spec.js\" -s 0", "build": "npm run clean && npm run compile && npm run lint && npm test", "watch": "npm run clean && npm run compile:watch" }, "gitHead": "d6a7960d5281d3dd5f8e2efba49bb552d090f562" } package/README.md000664 0000001527 3560116604 010546 0ustar00000000 000000 # @nodelib/fs.macchiato > A set of classes for easy testing of built-in structures of FS. ## Install ``` $ npm install @nodelib/fs.macchiato ``` ## Usage ```js import { Stats, Dirent } from '@nodelib/fs.macchiato'; const stats = new Stats(); const dirent = new Dirent(); ``` ## API ### `Stats` Creates a fake instance of `fs.Stats`. Can accept options to control parameter values. ```js const stats = new Stats({ isSymbolicLink: true, ino: 3 }); ``` ### `Dirent` Creates a fake instance of `fs.Dirent`. Can accept options to control parameter values. ```js const dirent = new Dirent({ isSymbolicLink: true }); ``` ## Changelog See the [Releases section of our GitHub project](https://github.com/nodelib/nodelib/releases) for changelogs for each release version. ## License This software is released under the terms of the MIT license. package/out/dirent.d.ts000664 0000000747 3560116604 012160 0ustar00000000 000000 /// import type * as fs from 'fs'; import type { PrepareOptionsFromClass } from './types'; export default class Dirent implements fs.Dirent { private readonly _options; readonly name: string; constructor(_options?: PrepareOptionsFromClass); isFile(): boolean; isDirectory(): boolean; isBlockDevice(): boolean; isCharacterDevice(): boolean; isSymbolicLink(): boolean; isFIFO(): boolean; isSocket(): boolean; } package/out/index.d.ts000664 0000000126 3560116604 011771 0ustar00000000 000000 import Dirent from './dirent'; import Stats from './stats'; export { Dirent, Stats }; package/out/stats.d.ts000664 0000001733 3560116604 012025 0ustar00000000 000000 /// import type * as fs from 'fs'; import type { PrepareOptionsFromClass } from './types'; export default class Stats implements fs.Stats { private readonly _options; readonly _date: Date; readonly dev: number; readonly ino: number; readonly mode: number; readonly nlink: number; readonly uid: number; readonly gid: number; readonly rdev: number; readonly size: number; readonly blksize: number; readonly blocks: number; readonly atimeMs: number; readonly mtimeMs: number; readonly ctimeMs: number; readonly birthtimeMs: number; readonly atime: Date; readonly mtime: Date; readonly ctime: Date; readonly birthtime: Date; constructor(_options?: PrepareOptionsFromClass); isFile(): boolean; isDirectory(): boolean; isBlockDevice(): boolean; isCharacterDevice(): boolean; isSymbolicLink(): boolean; isFIFO(): boolean; isSocket(): boolean; } package/out/types.d.ts000664 0000000675 3560116604 012037 0ustar00000000 000000 export declare type PrepareOptionsFromClass = { [TKey in keyof T]?: UnboxReturnTypeFromClassItem; }; export declare type UnboxReturnTypeFromClassItem = /** * Unbox return type from class method. */ T extends (...args: unknown[]) => infer TReturnType ? TReturnType : /** * Unbox return type from class property. */ T extends (infer TReturnType) ? TReturnType : /** * Default branch. Potentially impossible case. */ T;