UNPKG

nds-core

Version:

nds-core functionality for nds

54 lines (53 loc) 2.29 kB
var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "fs", "path"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.NodeAsync = void 0; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); class NodeAsync { static async readDirAsync(path) { const readDir = await Promise.resolve(fs_1.default.readdirSync); return readDir(path, { withFileTypes: true }); } static async existsAsync(path) { const exists = await Promise.resolve(fs_1.default.existsSync); return exists(path); } static async accessAsync(path, mode) { const access = await Promise.resolve(fs_1.default.accessSync); await access(path, mode); } static async mkdirAsync(path, options) { const mkdir = await Promise.resolve(fs_1.default.mkdirSync); return await mkdir(path, options); } static async unlinkAsync(path) { const unlink = await Promise.resolve(fs_1.default.unlinkSync); await unlink(path); } static async createWriteStreamAsync(path, options) { const writeStream = await Promise.resolve(fs_1.default.createWriteStream); return writeStream(path, options); } static async createReadStreamAsync(path, options) { const createReadStream = await Promise.resolve(fs_1.default.createReadStream); return createReadStream(path, options); } static async resolveAsync(...pathSegments) { const resolve = await Promise.resolve(path_1.default.resolve); return resolve(...pathSegments); } } exports.NodeAsync = NodeAsync; });