Skip to content

Commit 929a903

Browse files
committed
README: shorten code lines
1 parent 8ba2088 commit 929a903

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,15 @@ Note: method `waitTillAllExecutingJobsAreSettled` can be used to perform post-pr
5858
import { ZeroBackpressureSemaphore } from 'zero-backpressure-semaphore-typescript';
5959

6060
const maxConcurrentAggregationJobs = 24;
61-
const sensorAggregationSemaphore = new ZeroBackpressureSemaphore<void>(maxConcurrentAggregationJobs);
61+
const sensorAggregationSemaphore = new ZeroBackpressureSemaphore<void>(
62+
maxConcurrentAggregationJobs
63+
);
6264

6365
async function aggregateSensorsData(sensorUIDs: ReadonlyArray<string>) {
6466
for (const uid of sensorUIDs) {
65-
// Until the semaphore can start aggregating data from the current sensor, it won't make
66-
// sense to add more jobs, as such will induce unnecessary backpressure.
67+
// Until the semaphore can start aggregating data from the current sensor,
68+
// it won't make sense to add more jobs, as such will induce unnecessary
69+
// backpressure.
6770
await sensorAggregationSemaphore.startExecution(
6871
(): Promise<void> => handleDataAggregation(uid)
6972
);
@@ -79,7 +82,8 @@ async function aggregateSensorsData(sensorUIDs: ReadonlyArray<string>) {
7982
/**
8083
* Handles the data aggregation process for a specified IoT sensor.
8184
*
82-
* @param sensorUID - The unique identifier of the IoT sensor whose data is to be aggregated.
85+
* @param sensorUID - The unique identifier of the IoT sensor whose data is to
86+
* be aggregated.
8387
*/
8488
async function handleDataAggregation(sensorUID): Promise<void> {
8589
// Implementation goes here.
@@ -92,15 +96,17 @@ If the jobs might throw errors, you don't need to worry about these errors propa
9296
import { ZeroBackpressureSemaphore } from 'zero-backpressure-semaphore-typescript';
9397

9498
const maxConcurrentAggregationJobs = 24;
95-
const sensorAggregationSemaphore = // Notice the 2nd generic parameter (Error by default).
99+
const sensorAggregationSemaphore =
100+
// Notice the 2nd generic parameter (Error by default).
96101
new ZeroBackpressureSemaphore<void, SensorAggregationError>(
97102
maxConcurrentAggregationJobs
98103
);
99104

100105
async function aggregateSensorsData(sensorUIDs: ReadonlyArray<string>) {
101106
for (const uid of sensorUIDs) {
102-
// Until the semaphore can start aggregating data from the current sensor, it won't make
103-
// sense to add more jobs, as such will induce unnecessary backpressure.
107+
// Until the semaphore can start aggregating data from the current sensor,
108+
// it won't make sense to add more jobs, as such will induce unnecessary
109+
// backpressure.
104110
await sensorAggregationSemaphore.startExecution(
105111
(): Promise<void> => handleDataAggregation(uid)
106112
);
@@ -128,8 +134,10 @@ async function aggregateSensorsData(sensorUIDs: ReadonlyArray<string>) {
128134
/**
129135
* Handles the data aggregation process for a specified IoT sensor.
130136
*
131-
* @param sensorUID - The unique identifier of the IoT sensor whose data is to be aggregated.
132-
* @throws SensorAggregationError - Throws an error if the data aggregation process fails.
137+
* @param sensorUID - The unique identifier of the IoT sensor whose data is to
138+
* be aggregated.
139+
* @throws SensorAggregationError - Throws an error if the data aggregation
140+
* process fails.
133141
*/
134142
async function handleDataAggregation(sensorUID): Promise<void> {
135143
// Implementation goes here.

0 commit comments

Comments
 (0)