-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from gmaxlev/v1.3
v1.3
- Loading branch information
Showing
15 changed files
with
549 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { pictEntries } from "../../common/pict"; | ||
|
||
export function parseResult(result: string): Array<Record<string, string>> { | ||
const cases: any[] = []; | ||
|
||
for (const item of pictEntries(result)) { | ||
let currentCase; | ||
|
||
if (item.valueIndex === 0) { | ||
currentCase = {}; | ||
cases.push(currentCase); | ||
} else { | ||
currentCase = cases[cases.length - 1]; | ||
} | ||
|
||
currentCase[item.rowName as string] = item.value; | ||
|
||
cases[cases.length - 1] = currentCase; | ||
} | ||
|
||
return cases; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { ModelSource } from "./types"; | ||
import { isString } from "tsguarder"; | ||
import fsp from "fs/promises"; | ||
|
||
export async function getModelFromSource(source: ModelSource) { | ||
if (isString(source)) { | ||
return source; | ||
} | ||
|
||
try { | ||
const fileContent = await fsp.readFile(source.file); | ||
return fileContent.toString(); | ||
} catch (error) { | ||
console.error(`Error while reading model file. ${source.file}`); | ||
throw error; | ||
} | ||
} |
Oops, something went wrong.