mirror of
https://github.com/ritz078/transform.git
synced 2026-11-21 00:32:56 +03:00
* upgrade dependencies * upgrade dependencies * format code * update nextjs * fixes * chore: update graphql generator * fixes * fixes * fixes
38 lines
610 B
TypeScript
38 lines
610 B
TypeScript
import { BuiltInParserName } from "prettier";
|
|
import { prettify } from "@utils/prettify";
|
|
|
|
interface Data {
|
|
data: {
|
|
payload: {
|
|
value: string;
|
|
language: BuiltInParserName;
|
|
};
|
|
id: string | number;
|
|
};
|
|
}
|
|
|
|
const _self = self as any;
|
|
|
|
_self.onmessage = ({
|
|
data: {
|
|
payload: { value, language },
|
|
id,
|
|
},
|
|
}: Data) => {
|
|
(async function () {
|
|
try {
|
|
const payload = await prettify(language, value);
|
|
|
|
_self.postMessage({
|
|
id,
|
|
payload,
|
|
});
|
|
} catch (e) {
|
|
_self.postMessage({
|
|
id,
|
|
err: e.message,
|
|
});
|
|
}
|
|
})();
|
|
};
|