Home / File/ print.ts — astro Source File

print.ts — astro Source File

Architecture documentation for print.ts, a typescript file in the astro codebase. 1 imports, 0 dependents.

File typescript CoreAstro CoreMiddleware 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  b21f98d3_91a8_7255_af06_080fcafcb247["print.ts"]
  bf9f5367_fd3b_919a_78d3_86893e42ad6d["./host-route.js"]
  b21f98d3_91a8_7255_af06_080fcafcb247 --> bf9f5367_fd3b_919a_78d3_86893e42ad6d
  style b21f98d3_91a8_7255_af06_080fcafcb247 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { HostRoutes } from './host-route.js';

/**
 * Pretty print a list of definitions into the output format. Keeps
 * things readable for humans. Ex:
 * /nope               /                              301
 * /other              /                              301
 * /two                /                              302
 * /team/articles/*    /team/articles/*\/index.html    200
 * /blog/*             /team/articles/*\/index.html    301
 */
export function printAsRedirects(hostRoutes: HostRoutes) {
	const definitions = hostRoutes.definitions;
	const minInputLength = hostRoutes.minInputLength;
	const minTargetLength = hostRoutes.minTargetLength;
	let _redirects = '';

	// Loop over the definitions
	for (let i = 0; i < definitions.length; i++) {
		const definition = definitions[i];
		if (!definition.target) {
			continue;
		}
		// Figure out the number of spaces to add. We want at least 4 spaces
		// after the input. This ensure that all targets line up together.
		const inputSpaces = minInputLength - definition.input.length + 4;
		const targetSpaces = minTargetLength - definition.target.length + 4;
		_redirects +=
			(i === 0 ? '' : '\n') +
			definition.input +
			' '.repeat(inputSpaces) +
			definition.target +
			' '.repeat(Math.abs(targetSpaces)) +
			definition.status +
			(definition.force ? '!' : '');
	}

	return _redirects;
}

Domain

Subdomains

Functions

Dependencies

  • ./host-route.js

Frequently Asked Questions

What does print.ts do?
print.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, CoreMiddleware subdomain.
What functions are defined in print.ts?
print.ts defines 1 function(s): printAsRedirects.
What does print.ts depend on?
print.ts imports 1 module(s): ./host-route.js.
Where is print.ts in the architecture?
print.ts is located at packages/underscore-redirects/src/print.ts (domain: CoreAstro, subdomain: CoreMiddleware, directory: packages/underscore-redirects/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free