phase-1: optimize code
This commit is contained in:
@@ -5,15 +5,16 @@ const MAX_STORIES = 15;
|
||||
const TICKER_REGEX = /^[A-Z]{1,6}$/;
|
||||
|
||||
export class CatalystAnalyst {
|
||||
constructor() {
|
||||
constructor({ logger } = {}) {
|
||||
this.client = new YahooClient();
|
||||
this.logger = logger ?? { write: (msg) => process.stdout.write(msg) };
|
||||
}
|
||||
|
||||
async run() {
|
||||
process.stdout.write('🔍 Fetching market news...');
|
||||
this.logger.write('🔍 Fetching market news...');
|
||||
const stories = await this._fetchNews();
|
||||
const tickers = this._extractTickers(stories);
|
||||
process.stdout.write(` ${stories.length} stories, ${tickers.length} tickers\n`);
|
||||
this.logger.write(` ${stories.length} stories, ${tickers.length} tickers\n`);
|
||||
return { tickers, stories };
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user