@fre4x/yahoo-finance 1.0.53 → 1.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -38349,6 +38349,7 @@ function applyPagination(items, params) {
|
|
|
38349
38349
|
import * as fs from "node:fs/promises";
|
|
38350
38350
|
import * as path from "node:path";
|
|
38351
38351
|
import * as os from "node:os";
|
|
38352
|
+
import * as crypto from "node:crypto";
|
|
38352
38353
|
var PersistentCache = class {
|
|
38353
38354
|
cacheDir;
|
|
38354
38355
|
memoryCache = /* @__PURE__ */ new Map();
|
|
@@ -38360,7 +38361,7 @@ var PersistentCache = class {
|
|
|
38360
38361
|
await fs.mkdir(this.cacheDir, { recursive: true });
|
|
38361
38362
|
}
|
|
38362
38363
|
getFilePath(key) {
|
|
38363
|
-
const safeKey =
|
|
38364
|
+
const safeKey = crypto.createHash("sha256").update(key).digest("hex");
|
|
38364
38365
|
return path.join(this.cacheDir, `${safeKey}.json`);
|
|
38365
38366
|
}
|
|
38366
38367
|
async get(key) {
|
|
@@ -68565,9 +68566,11 @@ async function getNews(ticker) {
|
|
|
68565
68566
|
const cacheKey = JSON.stringify({ fn: "getNews", ticker });
|
|
68566
68567
|
return withCache(cacheKey, CACHE_TTL.NEWS, async () => {
|
|
68567
68568
|
if (isMock()) return [...MOCK_FIXTURES.getNews];
|
|
68568
|
-
const result = await yahooFinanceClient.search(
|
|
68569
|
-
|
|
68570
|
-
|
|
68569
|
+
const result = await yahooFinanceClient.search(
|
|
68570
|
+
ticker,
|
|
68571
|
+
{ newsCount: 20 },
|
|
68572
|
+
{ validateResult: false }
|
|
68573
|
+
);
|
|
68571
68574
|
return result.news ?? [];
|
|
68572
68575
|
});
|
|
68573
68576
|
}
|