From fbba64fdd48db26dee9ce6015cc92a8d83d3274a Mon Sep 17 00:00:00 2001 From: Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com> Date: Mon, 5 Jul 2021 11:27:18 +0200 Subject: [PATCH] fix: increase mem + round downloadRatio --- package.json | 4 ++-- src/npm/index.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index d4537f54e..ef290c1e3 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "doctoc": "doctoc --notitle --maxlevel 3 README.md", "lint": "eslint --ext=jsx,ts,tsx,js .", "prepare": "husky install", - "start": "UV_THREADPOOL_SIZE=12 node -r dotenv/config --async-stack-traces --max-old-space-size=420 dist/index.js", - "start_new": "indexName=npm-search-new bootstrapIndexName=npm-search-new.tmp UV_THREADPOOL_SIZE=22 node --async-stack-traces --max-old-space-size=420 dist/index.js", + "start": "UV_THREADPOOL_SIZE=12 node -r dotenv/config --async-stack-traces --max-old-space-size=920 dist/index.js", + "start_new": "indexName=npm-search-new bootstrapIndexName=npm-search-new.tmp UV_THREADPOOL_SIZE=22 node --async-stack-traces --max-old-space-size=920 dist/index.js", "test:watch": "jest --watchAll --no-watchman", "test": "jest --forceExit" }, diff --git a/src/npm/index.ts b/src/npm/index.ts index aa0885d8e..c405dea57 100644 --- a/src/npm/index.ts +++ b/src/npm/index.ts @@ -272,7 +272,9 @@ async function getDownloads(pkgs: Array>): Promise< const downloadsLast30Days = downloadsPerPkgName[name] ? downloadsPerPkgName[name].downloads : 0; - const downloadsRatio = (downloadsLast30Days / totalNpmDownloads) * 100; + const downloadsRatio = Number( + ((downloadsLast30Days / totalNpmDownloads) * 100).toFixed(4) + ); const popular = downloadsRatio > config.popularDownloadsRatio; const downloadsMagnitude = downloadsLast30Days ? downloadsLast30Days.toString().length