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

Function showFields

deps/npm/lib/commands/view.js:417–437  ·  view source on GitHub ↗
({ data, version, fields, json })

Source from the content-addressed store, hash-verified

415
416// return whatever was printed
417function showFields ({ data, version, fields, json }) {
418 const o = [data, version].reduce((acc, s) => {
419 Object.entries(s).forEach(([k, v]) => {
420 acc[k] = v
421 })
422 return acc
423 }, {})
424
425 const queryable = new Queryable(o)
426
427 if (!fields.length) {
428 return { [version.version]: queryable.query(Queryable.ALL) }
429 }
430
431 return fields.map((field) => {
432 const s = queryable.query(field, { unwrapSingleItemArrays: !json })
433 if (s) {
434 return { [version.version]: s }
435 }
436 })
437}
438
439function cleanup (data) {
440 if (Array.isArray(data)) {

Callers 1

#getDataMethod · 0.85

Calls 5

queryMethod · 0.95
reduceMethod · 0.80
forEachMethod · 0.65
mapMethod · 0.65
entriesMethod · 0.45

Tested by

no test coverage detected