import * as fastq from 'fastq'; import type { queueAsPromised } from 'fastq'; import { transformSceneNode } from '@plugin/transformers'; import { PenpotNode } from '@ui/types'; class Queue { private queue: queueAsPromised; constructor(worker: fastq.asyncWorker, concurrency: number) { this.queue = fastq.promise(worker, concurrency); } public enqueue(task: T): Promise { return this.queue.push(task); } public async waitIdle() { await this.queue.drain(); } } export const nodeQueue = new Queue( async ([sceneNode, position]: [SceneNode, number]): Promise<[PenpotNode | undefined, number]> => [ await transformSceneNode(sceneNode), position ], 1 );