From 86566ed658ef1ebb781732f83a2948d3c2379eb3 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Tue, 20 Feb 2024 20:18:51 +0300 Subject: [PATCH] chore: fallback parser code style edits --- src/parser/fallback.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/parser/fallback.js b/src/parser/fallback.js index 083f7e48..a93c9d20 100644 --- a/src/parser/fallback.js +++ b/src/parser/fallback.js @@ -6,23 +6,23 @@ import isCore from 'is-core-module'; import { resolve as resolveImports } from 'resolve.imports'; import { getContent } from '../utils/file'; -const extractPkgName = (value) => { - const [o, n] = value.split('/'); - return o[0] === '@' ? `${o}/${n}` : o; -}; - -const memo = new Map(); -const getClosesPkgJson = async (filename) => { +const pkgJsons = new Map(); +async function getClosesPkgJson(filename) { const cwd = path.dirname(filename); - if (memo.has(cwd)) return memo.get(cwd); + if (pkgJsons.has(cwd)) return pkgJsons.get(cwd); const pkgJson = Promise.resolve( getContent(findup('package.json', { cwd })).then(JSON.parse), ); - memo.set(cwd, pkgJson); + pkgJsons.set(cwd, pkgJson); return pkgJson; -}; +} + +function extractPkgName(value) { + const [o, n] = value.split('/'); + return o[0] === '@' ? `${o}/${n}` : o; +} export async function fallbackParser(filename) { const ext = path.extname(filename);