0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-17 22:44:24 -05:00

[ci] format

This commit is contained in:
natemoo-re 2023-01-30 20:13:41 +00:00 committed by fredkbot
parent 41e97158ba
commit 1a4cb6bc6e

View file

@ -1,14 +1,14 @@
import type { PropagationHint } from '../../@types/astro'; import type { PropagationHint } from '../../@types/astro';
import type { AstroComponentFactory } from './render/index.js';
import { AstroError, AstroErrorData } from '../../core/errors/index.js'; import { AstroError, AstroErrorData } from '../../core/errors/index.js';
import type { AstroComponentFactory } from './render/index.js';
function validateArgs(args: unknown[]): args is Parameters<AstroComponentFactory> { function validateArgs(args: unknown[]): args is Parameters<AstroComponentFactory> {
if (args.length !== 3) return false; if (args.length !== 3) return false;
if (!args[0] ||typeof args[0] !== 'object') return false; if (!args[0] || typeof args[0] !== 'object') return false;
return true; return true;
} }
function baseCreateComponent(cb: AstroComponentFactory, moduleId?: string): AstroComponentFactory { function baseCreateComponent(cb: AstroComponentFactory, moduleId?: string): AstroComponentFactory {
const name = moduleId?.split('/').pop()?.replace('.astro', '') ?? '' const name = moduleId?.split('/').pop()?.replace('.astro', '') ?? '';
const fn = (...args: Parameters<AstroComponentFactory>) => { const fn = (...args: Parameters<AstroComponentFactory>) => {
if (!validateArgs(args)) { if (!validateArgs(args)) {
throw new AstroError({ throw new AstroError({
@ -17,7 +17,7 @@ function baseCreateComponent(cb: AstroComponentFactory, moduleId?: string): Astr
}); });
} }
return cb(...args); return cb(...args);
} };
Object.defineProperty(fn, 'name', { value: name, writable: false }); Object.defineProperty(fn, 'name', { value: name, writable: false });
// Add a flag to this callback to mark it as an Astro component // Add a flag to this callback to mark it as an Astro component
fn.isAstroComponentFactory = true; fn.isAstroComponentFactory = true;