summaryrefslogtreecommitdiff
path: root/nodejs/lib/ships.ts
diff options
context:
space:
mode:
Diffstat (limited to 'nodejs/lib/ships.ts')
-rw-r--r--nodejs/lib/ships.ts24
1 files changed, 15 insertions, 9 deletions
diff --git a/nodejs/lib/ships.ts b/nodejs/lib/ships.ts
index 920cc21..e4875f8 100644
--- a/nodejs/lib/ships.ts
+++ b/nodejs/lib/ships.ts
@@ -25,15 +25,6 @@ import {
shortestPath,
} from './utils.ts';
-export async function getShips(): Promise<Array<Ship>> {
- const response = await send<Array<Ship>>({endpoint: `/my/ships`, page: 1});
- if (response.error) {
- debugLog(response);
- throw response;
- }
- return response.data.map(ship => new Ship(ship));
-}
-
export class Ship {
cargo: Cargo;
cooldown: Cooldown;
@@ -228,3 +219,18 @@ export class Ship {
return this.cargo;
}
}
+
+let myShips: Array<Ship> = [];
+
+export function getShips(): Array<Ship> {
+ return myShips;
+}
+
+export async function initShips(): Promise<void> {
+ const response = await send<Array<Ship>>({endpoint: `/my/ships`, page: 1});
+ if (response.error) {
+ debugLog(response);
+ throw response;
+ }
+ myShips = response.data.map(ship => new Ship(ship));
+}