Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#isIntervalPaused maybe useless #166

Open
KK-AI-LL opened this issue Aug 21, 2022 · 0 comments
Open

#isIntervalPaused maybe useless #166

KK-AI-LL opened this issue Aug 21, 2022 · 0 comments

Comments

@KK-AI-LL
Copy link

I'm reading source code to figure out how this lib works and I think #isIntervalPaused maybe useless and brings lots of related useless code.

if (!this.#isPaused) {
	const canInitializeInterval = !this.#isIntervalPaused;  // THIS IS USELESS , REMOVE IT
	if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {
		const job = this.#queue.dequeue();
		if (!job) {
			return false;
		}

		this.emit('active');
		job();

		if (canInitializeInterval) {  // CHANGE 'canInitializeInterval' TO ‘this.#intervalId === undefined’ and remove any code no longer used
			this.#initializeIntervalIfNeeded();
		}

		return true;
	}
}

As shown above, when code changes, all tests passed.

I found that these codes were introduced in this pr to enable p-queue the ability to throttle the queue, but #isIntervalPaused seems to be useless in this case, for that when I remove it from code as shown above, all test still passed, anyone can help me figure it out? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant