UNPKG

snyk-nodejs-lockfile-parser

Version:
20 lines 948 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractPkgsFromYarnLockV2 = void 0; const yarn_structs_1 = require("../../parsers/yarn-structs"); const utils_1 = require("./utils"); const utils_2 = require("../../utils"); const keyNormalizer = (0, utils_1.yarnLockFileKeyNormalizer)(yarn_structs_1.parseDescriptor, yarn_structs_1.parseRange); const extractPkgsFromYarnLockV2 = (yarnLockContent) => { const rawYarnLock = (0, utils_2.loadYamlMappingOrThrow)(yarnLockContent, 'yarn.lock'); delete rawYarnLock.__metadata; const dependencies = {}; Object.entries(rawYarnLock).forEach(([fullDescriptor, versionData]) => { keyNormalizer(fullDescriptor).forEach((descriptor) => { dependencies[descriptor] = versionData; }); }); return dependencies; }; exports.extractPkgsFromYarnLockV2 = extractPkgsFromYarnLockV2; //# sourceMappingURL=extract-yarnlock-v2-pkgs.js.map