Skip to content

Commit

Permalink
Just one flatten
Browse files Browse the repository at this point in the history
  • Loading branch information
jakearchibald committed Sep 15, 2020
1 parent 98fb5a5 commit 3be85aa
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/image-worker-plugin.js
Expand Up @@ -33,21 +33,21 @@ export default function () {
`// This file is autogenerated by lib/image-worker-plugin.js`,
`import { expose } from 'comlink';`,
`import { timed } from './util';`,
...dirs.map((dir) => `import ${dir} from './${dir}';`),
dirs.map((dir) => `import ${dir} from './${dir}';`),
`const exports = {`,
...dirs
.map((dir) => [
` ${dir}(`,
` ...args: Parameters<typeof ${dir}>`,
` ): ReturnType<typeof ${dir}> {`,
` return timed('${dir}', () => ${dir}(...args));`,
` },`,
`};`,
])
.flat(),
dirs.map((dir) => [
` ${dir}(`,
` ...args: Parameters<typeof ${dir}>`,
` ): ReturnType<typeof ${dir}> {`,
` return timed('${dir}', () => ${dir}(...args));`,
` },`,
`};`,
]),
`export type ProcessorWorkerApi = typeof exports;`,
`expose(exports, self);`,
].join('\n');
]
.flat(Infinity)
.join('\n');

await fsp.writeFile(path.join(base, 'index.ts'), file);
},
Expand Down

0 comments on commit 3be85aa

Please sign in to comment.