UNPKG

@busy-hour/blaze

Version:

<h1 align='center'>🔥 Blaze</h1> <div align='center'> An event driven framework for 🔥 Hono.js </div>

130 lines (129 loc) • 4.13 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var common_exports = {}; __export(common_exports, { crossRequire: () => crossRequire, hasOwnProperty: () => hasOwnProperty, isEmpty: () => isEmpty, isNil: () => isNil, isOnCjs: () => isOnCjs, loadFile: () => loadFile, mapToObject: () => mapToObject, removeTrailingSlash: () => removeTrailingSlash, resolvePromise: () => resolvePromise, toArray: () => toArray }); module.exports = __toCommonJS(common_exports); var import_node_fs = __toESM(require("node:fs"), 1); var import_node_module = require("node:module"); var import_node_path = __toESM(require("node:path"), 1); var import_logger = require("../internal/logger/index"); const import_meta = {}; function hasOwnProperty(obj, property) { return Object.hasOwn(obj, property); } function mapToObject(map, valueMapper) { return Array.from(map.entries()).reduce( (acc, [key, value]) => ({ ...acc, [key]: valueMapper ? valueMapper(value) : value }), {} ); } function toArray(value) { return Array.isArray(value) ? value : [value]; } function isNil(value) { return value === null || value === void 0; } function removeTrailingSlash(path2) { return path2.replace(/^\/+/, ""); } async function resolvePromise(promise) { try { const res = await promise; return [res, null]; } catch (err) { return [null, err]; } } function isEmpty(value) { if (Array.isArray(value)) { return value.length === 0; } if (value && typeof value === "object") { return Object.keys(value).length === 0; } return false; } function isOnCjs() { return typeof module !== "undefined" && typeof exports !== "undefined"; } function loadFile(id) { if (isOnCjs()) { return require(id); } if (!import_node_fs.default.existsSync(id)) { throw import_logger.Logger.throw(`${id} doesn't exist`); } if (import_node_fs.default.statSync(id).isDirectory()) { const infos = import_node_fs.default.readdirSync(id); const index = infos.find( (info) => info.match(/index\.[jt]s$|index\.[jt]x|index\.[cm][jt]s$/) ); if (!index) { throw import_logger.Logger.throw( `No index file found in directory ${id} (expected to find index.[jt]s or index.[jt]x or index.[cm][jt]s)` ); } return import(import_node_path.default.join(id, index)); } return import(id); } function crossRequire(id) { if (isOnCjs()) { return require(id); } const esmRequire = (0, import_node_module.createRequire)(import_meta.url); return esmRequire(id); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { crossRequire, hasOwnProperty, isEmpty, isNil, isOnCjs, loadFile, mapToObject, removeTrailingSlash, resolvePromise, toArray });