refactor: init

This commit is contained in:
Ibrahima G. Coulibaly
2025-04-05 04:36:22 +00:00
parent 3014443163
commit ab503c642d
18 changed files with 197 additions and 238 deletions

View File

@@ -1,10 +0,0 @@
import type { DataTable } from '../types';
import wiregauge from './wire_gauge';
import material_electrical_properties from './material_electrical_properties';
const allDataTables: { [key: string]: DataTable } = {
'wire-gauge': wiregauge,
'material-electrical-properties': material_electrical_properties
};
export default allDataTables;

View File

@@ -1,18 +1,8 @@
import type { DataTable } from './types.ts';
export async function getDataTable(name: string): Promise<DataTable> {
const allDataTables = (await import('./data/index')).default;
return allDataTables[name];
}
/* Used in case later we want any kind of computed extra data */
export function dataTableLookup(table: DataTable, key: string): any {
return table.data[key];
}
export async function listDataTables(): Promise<{ [name: string]: DataTable }> {
const allDataTables = (await import('./data/index')).default;
return allDataTables;
}
export { DataTable };

View File

@@ -1,4 +1,4 @@
/*
/*
Represents a set of rows indexed by a key.
Used for calculator presets
@@ -7,7 +7,7 @@ export interface DataTable {
title: string;
/* A JSON schema properties */
columns: {
[key: string]: any;
[key: string]: { title: string; type: string; unit: string };
};
data: {
[key: string]: {