Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip convert processors to ts #2701

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Console } from 'console';
import readline from 'readline';
import processAllPlayers from './processAllPlayers.mjs';
import processTeamfights from './processTeamfights.mjs';
import processParsedData from './processParsedData.mjs';
import processMetadata from './processMetadata.mjs';
import processExpand from './processExpand.mjs';
import processDraftTimings from './processDraftTimings.mjs';
import parseSchema from './parseSchema.mjs';
import processAllPlayers from './processAllPlayers.js';
import processTeamfights from './processTeamfights.js';
import processParsedData from './processParsedData.js';
import processMetadata from './processMetadata.js';
import processExpand from './processExpand.js';
import processDraftTimings from './processDraftTimings.js';
import parseSchema from './parseSchema.js';

function createParsedDataBlob(entries, matchId) {
function createParsedDataBlob(entries: any[], matchId: string) {
const logConsole = new Console(process.stderr);
logConsole.time('metadata');
const meta = processMetadata(entries);
Expand All @@ -33,13 +33,13 @@ function createParsedDataBlob(entries, matchId) {
parsedData.radiant_xp_adv = ap.radiant_xp_adv;
return parsedData;
}
const entries = [];
const entries: any[] = [];
let complete = false;
const matchId = process.argv[2];
const parseStream = readline.createInterface({
input: process.stdin,
});
parseStream.on('line', (e) => {
parseStream.on('line', (e: any) => {
e = JSON.parse(e);
entries.push(e);
if (e.type === 'epilogue') {
Expand All @@ -49,7 +49,7 @@ parseStream.on('line', (e) => {
parseStream.on('close', () => {
if (complete) {
const parsedData = createParsedDataBlob(entries, matchId);
process.stdout.write(JSON.stringify(parsedData), null, (err) => {
process.stdout.write(JSON.stringify(parsedData), undefined, (err) => {
process.exit(Number(err));
});
} else {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion processors/populate.mjs → processors/populate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import performanceOthers from './performanceOthers.mjs';
import performanceOthers from './performanceOthers.js';
function populate(e, container, meta) {
let t;
switch (e.type) {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Given an event stream, extracts metadata such as game zero time and hero to slot/ID mappings.
* */
function processMetadata(entries) {
function processMetadata(entries: any[]) {
const heroToSlot = {};
const slotToPlayerslot = {};
const heroIdToSlot = {};
Expand Down Expand Up @@ -47,6 +47,7 @@ function processMetadata(entries) {
slot_to_playerslot: slotToPlayerslot,
hero_id_to_slot: heroIdToSlot,
ability_levels: abilityLevels,
match_id: '',
};
}
export default processMetadata;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import populate from './populate.mjs';
import populate from './populate.js';
function processParsedData(entries, container, meta) {
for (let i = 0; i < entries.length; i += 1) {
const e = entries[i];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import populate from './populate.mjs';
import populate from './populate.js';
/**
* A processor to compute teamfights that occurred given an event stream
* */
Expand Down
File renamed without changes.
Loading