Skip to content

Commit

Permalink
add JSDOC for urban file logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MutazAshhab committed Oct 27, 2023
1 parent 7588f85 commit b050cb1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/logic/urbanflo-file-logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import {
useSimulationHistory,
} from '~/zustand/useSimulationHistory';

/**
* Defines the structure of an UrbanFlo file.
*/
interface UrbanFloFile {
version: number;
networkData: NetworkData;
Expand All @@ -14,6 +17,11 @@ interface UrbanFloFile {
};
}

/**
* Returns the content of an UrbanFlo file as a string.
*
* @returns {string} - String representation of the UrbanFlo file.
*/
export function getUrbanFloFileContents(): string {
const fileContents = getFileContents();

Expand All @@ -22,6 +30,11 @@ export function getUrbanFloFileContents(): string {
return jsonString;
}

/**
* Retrieves the contents required for an UrbanFlo file.
*
* @returns {UrbanFloFile} - The contents of the UrbanFlo file.
*/
function getFileContents(): UrbanFloFile {
const networkStore = useNetworkStore.getState();
const simulationHistoryStore = useSimulationHistory.getState();
Expand All @@ -45,6 +58,12 @@ function getFileContents(): UrbanFloFile {
};
}

/**
* Converts a JSON object to an UrbanFloFile.
*
* @param {unknown} json - The JSON object to be converted.
* @returns {UrbanFloFile} - The UrbanFloFile representation of the provided JSON.
*/
export function getNetworkFromUploadedFile(json: unknown): UrbanFloFile {
return json as UrbanFloFile;
}

0 comments on commit b050cb1

Please sign in to comment.