accidental commit.

This commit is contained in:
Robin Heggelund Hansen 2021-07-14 12:32:04 +02:00
parent 5e16fe457b
commit 36e77be58a
2 changed files with 13 additions and 15 deletions

View File

@ -56,14 +56,7 @@ async function run(inputFilePath: string | undefined) {
verbose: true,
assetSizes: true,
runBenchmark: [
{
browser: Browser.Chrome,
headless: true,
},
{
browser: Browser.V8JitLog,
headless: true,
},
{ browser: Browser.Firefox }
],
transforms: { ...benchmarkDefaults, ...{replacements: replacements} }
};

View File

@ -2,7 +2,6 @@ import ts from 'typescript';
export const recordUpdate = (): ts.TransformerFactory<ts.SourceFile> =>
(context) => (sourceFile) => {
console.log('record update');
const registry = new RecordRegistry();
ts.visitNode(sourceFile, replaceObjectLiterals(registry, context));
return sourceFile;
@ -18,23 +17,29 @@ class RecordRegistry {
this.map = new Map();
}
register(recordAst: ts.Node) {
register(recordAst: ts.Node): String {
console.log(recordAst);
}
}
function replaceObjectLiterals(_registry: RecordRegistry, _ctx: ts.TransformationContext) {
function replaceObjectLiterals(_registry: RecordRegistry, ctx: ts.TransformationContext) {
const visitorHelp = (node: ts.Node): ts.VisitResult<ts.Node> => {
if (isRecordLiteral(node)) {
return node;
const visitedNode = ts.visitEachChild(node, visitorHelp, ctx);
if (!isRecordLiteral(visitedNode)) {
return visitedNode;
}
return node;
const recordClassName = registry.register(visitedNode);
console.log(recordClassName);
return visitedNode;
}
return visitorHelp;
}
function isRecordLiteral(node: ts.Node): boolean {
return ts.isObjectLiteralExpression(node);
return ts.isObjectLiteralExpression(node) &&
node.properties.length > 0 &&
node.properties[0].name.text !== '$';
}