Skip to content

Commit

Permalink
Added Random Number Function
Browse files Browse the repository at this point in the history
  • Loading branch information
sahilchaddha committed May 19, 2018
1 parent 0f8eecc commit 1a2ac7e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/service/stream.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class StreamService implements IService {
StreamService.cachedPayload = payload
}
this.stream.push(StreamService.cachedPayload)
}, this.delay * 1000) // into Seconds
}, this.getRandomNumber() * 1000) // into Seconds
}
}

Expand All @@ -50,6 +50,10 @@ class StreamService implements IService {
logger.verbose({message: "Reading file payload.txt", category: this.serviceName})
return fs.readFileSync(path.join(__dirname, "..", "payload", "payload.txt"), "utf8").toString()
}

private getRandomNumber(): number {
return Math.floor((Math.random() * this.delay) + 1)
}
}

export default StreamService

0 comments on commit 1a2ac7e

Please sign in to comment.