Skip to content

Commit

Permalink
Better naming
Browse files Browse the repository at this point in the history
  • Loading branch information
smikhalevski committed Dec 11, 2023
1 parent 0f2a40a commit aaab6d0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ npm install --save-prod parallel-universe
- [`Lock`](#lock)
- [`Blocker`](#blocker)
- [`PubSub`](#pubsub)
- [`untilTruthy`](#untiltruthy)
- [`repeatUntil`](#repeatuntil)
- [`sleep`](#sleep)
- [`raceTimeout`](#racetimeout)
Expand Down Expand Up @@ -321,7 +320,7 @@ pubSub.publish('Pluto');

# `repeatUntil`

Invokes a callback until the condition is met.
Invokes a callback multiple times until the condition is met.

```ts
repeatUntil(
Expand Down
6 changes: 3 additions & 3 deletions src/main/WorkPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class WorkPool {
/**
* The queue that holds submitted jobs.
*/
private _queue = new AsyncQueue<Job>();
private _jobQueue = new AsyncQueue<Job>();

/**
* Active workers and workers with pending termination.
Expand Down Expand Up @@ -48,7 +48,7 @@ export class WorkPool {
*/
submit<T>(cb: AbortableCallback<T>): Promise<T> {
return new Promise((resolve, reject) => {
this._queue.add({ callback: cb, resolve, reject });
this._jobQueue.add({ callback: cb, resolve, reject });
});
}

Expand Down Expand Up @@ -89,7 +89,7 @@ export class WorkPool {

// Spawn additional workers
for (let i = 0; i < size; ++i) {
_workers.push(new Worker(this._queue));
_workers.push(new Worker(this._jobQueue));
}

return Promise.all(promises).then(noop);
Expand Down
2 changes: 1 addition & 1 deletion src/main/raceSignals.ts → src/main/composeSignals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @param signals The signals to observe.
*/
export function raceSignals(signals: AbortSignal[]): AbortSignal {
export function composeSignals(signals: AbortSignal[]): AbortSignal {
const abortController = new AbortController();

const abortListener = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { Executor } from './Executor';
export { Lock } from './Lock';
export { PubSub } from './PubSub';
export { WorkPool } from './WorkPool';
export { raceSignals } from './raceSignals';
export { composeSignals } from './composeSignals';
export { raceTimeout } from './raceTimeout';
export { repeatUntil } from './repeatUntil';
export { sleep } from './sleep';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { raceSignals } from '../main';
import { composeSignals } from '../main';

describe('raceSignals', () => {
describe('composeSignals', () => {
test('aborts if any of signals is aborted', () => {
const abortController1 = new AbortController();
const abortController2 = new AbortController();

const signal = raceSignals([abortController1.signal, abortController2.signal]);
const signal = composeSignals([abortController1.signal, abortController2.signal]);

expect(signal.aborted).toBe(false);

Expand All @@ -20,7 +20,7 @@ describe('raceSignals', () => {

abortController2.abort();

const signal = raceSignals([abortController1.signal, abortController2.signal]);
const signal = composeSignals([abortController1.signal, abortController2.signal]);

expect(signal.aborted).toBe(true);
});
Expand Down

0 comments on commit aaab6d0

Please sign in to comment.