MCPcopy Index your code
hub / github.com/nodejs/node / #json

Method #json

deps/npm/lib/commands/outdated.js:270–291  ·  view source on GitHub ↗
(list)

Source from the content-addressed store, hash-verified

268 }
269
270 #json (list) {
271 // TODO(BREAKING_CHANGE): this should just return an array.
272 // It's a list and turning it into an object with keys is lossy since multiple items in the list could have the same key. For now we hack that by only changing top level values into arrays if they have multiple outdated items
273 return list.reduce((acc, d) => {
274 const dep = {
275 current: d.current,
276 wanted: d.wanted,
277 latest: d.latest,
278 dependent: d.dependent,
279 location: d.path,
280 ...this.npm.config.get('long') ? {
281 type: d.type,
282 homepage: d.homepage,
283 dependedByLocation: d.dependedByLocation } : {},
284 }
285 acc[d.name] = acc[d.name]
286 // If this item already has an outdated dep then we turn it into an array
287 ? (Array.isArray(acc[d.name]) ? acc[d.name] : [acc[d.name]]).concat(dep)
288 : dep
289 return acc
290 }, {})
291 }
292}
293
294module.exports = Outdated

Callers 1

execMethod · 0.95

Calls 3

reduceMethod · 0.80
concatMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected