changes
This commit is contained in:
@@ -2,8 +2,15 @@ import router from "../router";
|
|||||||
import { default as paginate } from "express-paginate";
|
import { default as paginate } from "express-paginate";
|
||||||
import { walkFolder, extractArchive, getCovers } from "../../utils/fs.utils";
|
import { walkFolder, extractArchive, getCovers } from "../../utils/fs.utils";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { IExtractionOptions } from "../../interfaces/folder.interface";
|
|
||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
|
import fs from "fs";
|
||||||
|
|
||||||
|
import { IExtractionOptions } from "../../interfaces/folder.interface";
|
||||||
|
const { chain } = require("stream-chain");
|
||||||
|
const { parser } = require("stream-json");
|
||||||
|
const { pick } = require("stream-json/filters/Pick");
|
||||||
|
const { ignore } = require("stream-json/filters/Ignore");
|
||||||
|
const { streamValues } = require("stream-json/streamers/StreamValues");
|
||||||
|
|
||||||
router.route("/getComicCovers").post(async (req: Request, res: Response) => {
|
router.route("/getComicCovers").post(async (req: Request, res: Response) => {
|
||||||
typeof req.body.extractionOptions === "object"
|
typeof req.body.extractionOptions === "object"
|
||||||
@@ -13,6 +20,22 @@ router.route("/getComicCovers").post(async (req: Request, res: Response) => {
|
|||||||
req.body.extractionOptions,
|
req.body.extractionOptions,
|
||||||
req.body.walkedFolders,
|
req.body.walkedFolders,
|
||||||
);
|
);
|
||||||
|
const pipeline = chain([
|
||||||
|
fs.createReadStream(foo),
|
||||||
|
parser(),
|
||||||
|
// pick({ filter: "data" }),
|
||||||
|
streamValues(),
|
||||||
|
(data) => {
|
||||||
|
const value = data.value;
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
let counter = 0;
|
||||||
|
pipeline.on("data", () => ++counter);
|
||||||
|
pipeline.on("end", () =>
|
||||||
|
console.log(`The accounting department has ${counter} employees.`),
|
||||||
|
);
|
||||||
return res.json(foo);
|
return res.json(foo);
|
||||||
// if (
|
// if (
|
||||||
// _.isArray(foo) &&
|
// _.isArray(foo) &&
|
||||||
|
|||||||
Reference in New Issue
Block a user