JSTQL-JS-Transform/src/index.ts

37 lines
749 B
TypeScript
Raw Normal View History

import * as babelparser from "../babel/packages/babel-parser";
2023-12-11 18:38:30 +00:00
import { parseApplicableTo } from "./parser/parse";
import { TransformRecipe, transform } from "./transform/transform";
2023-12-06 17:48:30 +00:00
/*
proposal await_to_promise {
applicable to {
let a = await b();
2023-12-11 18:38:30 +00:00
<<CONSUME>>
2023-12-06 17:48:30 +00:00
}
transform to {
b().then((a) => {
console.log(a);
})
}
}
*/
2023-12-11 18:38:30 +00:00
const transformExample:TransformRecipe = {
applicableTo: `let a = await b();<<REST_BLOCK:rest>>`,
consumeBlock: true,
identifiers: ["b", "a", "rest"],
transformTo: "b().then((a) => {<<REST_BLOCK:rest>>})"
}
const code = "let a = await b(); console.log(a);"
const main = (): void => {
transform(transformExample, code);
2023-12-06 17:48:30 +00:00
2023-12-11 18:38:30 +00:00
2023-12-06 17:48:30 +00:00
2023-12-11 18:38:30 +00:00
};
main();