MCPcopy Create free account
hub / github.com/nodejs/node / cleanup

Function cleanup

deps/npm/lib/commands/view.js:439–460  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

437}
438
439function cleanup (data) {
440 if (Array.isArray(data)) {
441 return data.map(cleanup)
442 }
443
444 if (!data || typeof data !== 'object') {
445 return data
446 }
447
448 const keys = Object.keys(data)
449
450 if (keys.length <= 3 && data.name && (
451 (keys.length === 1) ||
452 (keys.length === 3 && data.email && data.url) ||
453 (keys.length === 2 && (data.email || data.url)) ||
454 data.trustedPublisher
455 )) {
456 data = unparsePerson(data)
457 }
458
459 return data
460}
461
462const unparsePerson = (d) =>
463 `${d.name}${d.email ? ` <${d.email}>` : ''}${d.url ? ` (${d.url})` : ''}`

Callers 1

#packageOutputMethod · 0.70

Calls 3

unparsePersonFunction · 0.85
mapMethod · 0.65
keysMethod · 0.65

Tested by

no test coverage detected