Home / File/ _util.js — astro Source File

_util.js — astro Source File

Architecture documentation for _util.js, a javascript file in the astro codebase. 2 imports, 6 dependents.

File javascript PerformanceBenchmarking MetricsCalculator 2 imports 6 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  4265c711_d908_961d_b7f8_d10af2c1c59b["_util.js"]
  3955a637_4c78_0528_fe7c_92190a232cb0["node:module"]
  4265c711_d908_961d_b7f8_d10af2c1c59b --> 3955a637_4c78_0528_fe7c_92190a232cb0
  c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"]
  4265c711_d908_961d_b7f8_d10af2c1c59b --> c52a5f83_66e3_37d7_9ebb_767f7129bc62
  4f5ebd66_3fdf_8047_4c83_d856ee583eeb["cli-startup.js"]
  4f5ebd66_3fdf_8047_4c83_d856ee583eeb --> 4265c711_d908_961d_b7f8_d10af2c1c59b
  4855f18f_6cc0_6561_6bbb_0ad232d1f185["codspeed-setup.js"]
  4855f18f_6cc0_6561_6bbb_0ad232d1f185 --> 4265c711_d908_961d_b7f8_d10af2c1c59b
  b65fc43f_6458_b0c9_e367_578ca2d1c391["memory.js"]
  b65fc43f_6458_b0c9_e367_578ca2d1c391 --> 4265c711_d908_961d_b7f8_d10af2c1c59b
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d["render.js"]
  3c790668_be1c_58e1_f783_4e3a5b4e3a0d --> 4265c711_d908_961d_b7f8_d10af2c1c59b
  84e8dcec_8779_ed84_459a_2c92f21c0f63["server-stress.js"]
  84e8dcec_8779_ed84_459a_2c92f21c0f63 --> 4265c711_d908_961d_b7f8_d10af2c1c59b
  55347ca2_52cb_1c86_118a_1b626edf2916["index.js"]
  55347ca2_52cb_1c86_118a_1b626edf2916 --> 4265c711_d908_961d_b7f8_d10af2c1c59b
  style 4265c711_d908_961d_b7f8_d10af2c1c59b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { createRequire } from 'node:module';
import path from 'node:path';

const astroPkgPath = createRequire(import.meta.url).resolve('astro/package.json');

export const astroBin = path.resolve(astroPkgPath, '../bin/astro.mjs');

/** @typedef {{ avg: number, stdev: number, max: number }} Stat */

/**
 * @param {number[]} numbers
 * @returns {Stat}
 */
export function calculateStat(numbers) {
	const avg = numbers.reduce((a, b) => a + b, 0) / numbers.length;
	const stdev = Math.sqrt(
		numbers.map((x) => Math.pow(x - avg, 2)).reduce((a, b) => a + b, 0) / numbers.length,
	);
	const max = Math.max(...numbers);
	return { avg, stdev, max };
}

export async function makeProject(name) {
	console.log('Making project:', name);
	const projectDir = new URL(`../projects/${name}/`, import.meta.url);

	const makeProjectMod = await import(`../make-project/${name}.js`);
	await makeProjectMod.run(projectDir);

	console.log('Finished making project:', name);
	return projectDir;
}

Subdomains

Dependencies

  • node:module
  • node:path

Frequently Asked Questions

What does _util.js do?
_util.js is a source file in the astro codebase, written in javascript. It belongs to the PerformanceBenchmarking domain, MetricsCalculator subdomain.
What functions are defined in _util.js?
_util.js defines 2 function(s): calculateStat, makeProject.
What does _util.js depend on?
_util.js imports 2 module(s): node:module, node:path.
What files import _util.js?
_util.js is imported by 6 file(s): cli-startup.js, codspeed-setup.js, index.js, memory.js, render.js, server-stress.js.
Where is _util.js in the architecture?
_util.js is located at benchmark/bench/_util.js (domain: PerformanceBenchmarking, subdomain: MetricsCalculator, directory: benchmark/bench).

Analyze Your Own Codebase

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

Try Supermodel Free