mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-03 21:13:49 +01:00
7b993f3550
Also refactor to dedup our own download code
19 lines
737 B
TypeScript
19 lines
737 B
TypeScript
import type { BaseServer } from "../Server/BaseServer";
|
|
import { ScriptFilePath } from "./ScriptFilePath";
|
|
import { TextFilePath } from "./TextFilePath";
|
|
|
|
/** Provide a common interface for accessing script and text files */
|
|
export type ContentFilePath = ScriptFilePath | TextFilePath;
|
|
export interface ContentFile {
|
|
filename: ContentFilePath;
|
|
content: string;
|
|
deleteFromServer: (server: BaseServer) => boolean;
|
|
}
|
|
export type ContentFileMap = Map<ContentFilePath, ContentFile>;
|
|
|
|
/** Generator function to allow iterating through all content files on a server */
|
|
export function* allContentFiles(server: BaseServer): Generator<[ContentFilePath, ContentFile], void, undefined> {
|
|
yield* server.scripts;
|
|
yield* server.textFiles;
|
|
}
|