Cleaning
This commit is contained in:
parent
8b38f7bc1f
commit
ba60669391
|
@ -5,7 +5,7 @@ import GelbooruApiService from "./GelbooruApiService";
|
||||||
|
|
||||||
class ImageService {
|
class ImageService {
|
||||||
postsQueue: Image[] = [];
|
postsQueue: Image[] = [];
|
||||||
|
|
||||||
async get(): Promise<Image> {
|
async get(): Promise<Image> {
|
||||||
while (this.postsQueue.length === 0) {
|
while (this.postsQueue.length === 0) {
|
||||||
const validPosts = await this.getNewValidImages();
|
const validPosts = await this.getNewValidImages();
|
||||||
|
@ -13,6 +13,7 @@ class ImageService {
|
||||||
}
|
}
|
||||||
return this.postsQueue.pop() as Image;
|
return this.postsQueue.pop() as Image;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getNewValidImages(): Promise<Image[]> {
|
private async getNewValidImages(): Promise<Image[]> {
|
||||||
const gelbooruResponse: GelbooruServiceResponse = await GelbooruApiService.get();
|
const gelbooruResponse: GelbooruServiceResponse = await GelbooruApiService.get();
|
||||||
const posts = gelbooruResponse.posts;
|
const posts = gelbooruResponse.posts;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { afterEach, beforeAll, describe, expect, it, mock } from "bun:test";
|
import { describe, expect, it, mock } from "bun:test";
|
||||||
import Image from "../src/types/Image"
|
import Image from "../src/types/Image"
|
||||||
import ImageService from "../src/services/ImageService";
|
import ImageService from "../src/services/ImageService";
|
||||||
import GelbooruApiResponse from "../src/types/GelbooruServiceResponse";
|
import GelbooruApiResponse from "../src/types/GelbooruServiceResponse";
|
||||||
|
|
Loading…
Reference in New Issue