core: 支持题目导出

This commit is contained in:
undefined committed 2020-11-07 23:47:35 +08:00
1 parent a5004a7c1b
commit ee0f5deedc
11 files changed
+87 -33

No files matched your search

+8
View File
@@ -1,4 +1,5 @@
import fs from 'fs';
import { Duplex } from 'stream';
import cluster from 'cluster';
import path from 'path';
import serialize from 'serialize-javascript';
@@ -180,6 +181,13 @@ export function streamToBuffer(stream): Promise<Buffer> {
});
}
export function bufferToStream(buffer: Buffer): NodeJS.ReadableStream {
const stream = new Duplex();
stream.push(buffer);
stream.push(null);
return stream;
}
export function buildProjection(fields: string[]): Record<string, 1> {
const o = {};
for (const k of fields) o[k] = 1;