@elastic.io/oih-standard-library
Advanced tools
Comparing version
@@ -92,3 +92,3 @@ export declare abstract class PollingTrigger { | ||
*/ | ||
emitAll(results: any): Promise<any>; | ||
emitAll(results: any): Promise<void>; | ||
/** | ||
@@ -95,0 +95,0 @@ * |
@@ -30,5 +30,2 @@ "use strict"; | ||
this.logger.trace('Polled objects: %j', result); | ||
if (result.length === 0) { | ||
break; | ||
} | ||
await this.emitIndividually(result); | ||
@@ -41,5 +38,2 @@ break; | ||
this.logger.trace('Polled objects: %j', result); | ||
if (result.length === 0) { | ||
break; | ||
} | ||
await this.emitAll(result); | ||
@@ -192,5 +186,4 @@ break; | ||
this.logger.trace('Polled next page and objects: %j', result); | ||
if (result.objects.length > 0) { | ||
await this.emitAll(result.objects); | ||
} | ||
const { objects } = result; | ||
await this.emitAll(objects); | ||
return result.nextPage; | ||
@@ -203,5 +196,11 @@ } | ||
async emitIndividually(results) { | ||
for (const r of results) { | ||
this.logger.trace('Emitting new message with body: %j', r); | ||
await this.emit('data', messages.newMessageWithBody(r)); | ||
for (let i = 0; i < results.length; i++) { | ||
const r = results[i]; | ||
if (r === null || r === undefined) { | ||
this.logger.trace('Not emitting result with empty body, result was: %j', r); | ||
} | ||
else { | ||
this.logger.trace('Emitting new message with body: %j', r); | ||
await this.emit('data', messages.newMessageWithBody(r)); | ||
} | ||
} | ||
@@ -214,4 +213,8 @@ } | ||
async emitAll(results) { | ||
if (results === null || results === undefined || results.length === 0) { | ||
this.logger.trace('Not emitting result with empty body, results was: %j', results); | ||
return; | ||
} | ||
this.logger.trace('Emitting new message with body: %j', results); | ||
return this.emit('data', messages.newMessageWithBody(results)); | ||
await this.emit('data', messages.newMessageWithBody(results)); | ||
} | ||
@@ -218,0 +221,0 @@ } |
@@ -37,5 +37,2 @@ import { | ||
this.logger.trace('Polled objects: %j', result); | ||
if (result.length === 0) { | ||
break; | ||
} | ||
await this.emitIndividually(result); | ||
@@ -48,5 +45,2 @@ break; | ||
this.logger.trace('Polled objects: %j', result); | ||
if (result.length === 0) { | ||
break; | ||
} | ||
await this.emitAll(result); | ||
@@ -207,5 +201,4 @@ break; | ||
this.logger.trace('Polled next page and objects: %j', result); | ||
if (result.objects.length > 0) { | ||
await this.emitAll(result.objects); | ||
} | ||
const { objects } = result; | ||
await this.emitAll(objects); | ||
return result.nextPage; | ||
@@ -219,5 +212,10 @@ } | ||
public async emitIndividually(results: Array<any>) { | ||
for (const r of results) { | ||
this.logger.trace('Emitting new message with body: %j', r); | ||
await this.emit('data', messages.newMessageWithBody(r)); | ||
for (let i = 0; i < results.length; i++) { | ||
const r = results[i]; | ||
if (r === null || r === undefined) { | ||
this.logger.trace('Not emitting result with empty body, result was: %j', r); | ||
} else { | ||
this.logger.trace('Emitting new message with body: %j', r); | ||
await this.emit('data', messages.newMessageWithBody(r)); | ||
} | ||
} | ||
@@ -231,4 +229,8 @@ } | ||
public async emitAll(results: any) { | ||
if (results === null || results === undefined || results.length === 0) { | ||
this.logger.trace('Not emitting result with empty body, results was: %j', results); | ||
return; | ||
} | ||
this.logger.trace('Emitting new message with body: %j', results); | ||
return this.emit('data', messages.newMessageWithBody(results)); | ||
await this.emit('data', messages.newMessageWithBody(results)); | ||
} | ||
@@ -235,0 +237,0 @@ |
{ | ||
"name": "@elastic.io/oih-standard-library", | ||
"version": "0.0.10-dev.15", | ||
"version": "0.0.10-dev.16", | ||
"description": "Library for OIH standards implementation", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
165408
0.42%2435
0.21%