MCPcopy Create free account
hub / github.com/XmirrorSecurity/OpenSCA-cli / ReadNpmJson

Function ReadNpmJson

opensca/sca/javascript/npm.go:347–357  ·  view source on GitHub ↗
(reader io.Reader, version string)

Source from the content-addressed store, hash-verified

345}
346
347func ReadNpmJson(reader io.Reader, version string) *PackageJson {
348 npm := readJson[NpmJson](reader)
349 if npm == nil {
350 return nil
351 }
352 vers := []string{}
353 for v := range npm.Versions {
354 vers = append(vers, v)
355 }
356 return npm.Versions[FindMaxVersion(version, vers)]
357}
358
359// FindMaxVersion 从一组版本中查找符合版本约束的最大版本
360// version: 范围约束

Callers 2

initFunction · 0.92
npm.goFile · 0.85

Calls 1

FindMaxVersionFunction · 0.70

Tested by

no test coverage detected