This commit is contained in:
2021-05-07 14:24:31 -07:00
parent 62c63de1fd
commit d35f4b50b4
4 changed files with 60 additions and 27 deletions

View File

@@ -3,10 +3,11 @@ import {
extractCoverFromComicBookArchive,
} from "../actions/fileops.actions";
import { IExtractedComicBookCoverFile } from "../../server/interfaces/folder.interface";
const ndjsonStream = require("can-ndjson-stream");
export const greet = async (
path: string,
): Promise<IExtractedComicBookCoverFile[] | unknown> => {
): Promise<IExtractedComicBookCoverFile[] | unknown | any> => {
const targetOptions = {
sourceFolder: path,
extractTarget: "all",
@@ -27,5 +28,16 @@ export const greet = async (
},
fileObjects,
);
return JSON.stringify(fo);
const reader = await ndjsonStream(fo).getReader();
reader.read().then(function process({ done, value }) {
if (done) {
console.log("done");
return;
}
console.log(value);
return reader.read().then(process);
});
// return JSON.stringify(fo);
};