stat = async (ipfs, cidOrPath) => {
  const hashOrPath = cidOrPath.toString()
  const path = hashOrPath.startsWith('/')
    ? hashOrPath
    : `/ipfs/${hashOrPath}`

  try {
    let stats
    if (path.startsWith('/ipfs/')) {
      stats = await memStat(path, ipfs)
    } else {
      stats = await ipfs.files.stat(path)
    }
    return { path, ...stats }
  } catch (e) {
    // Discard error and mark DAG as 'unknown' to unblock listing other pins.
    // Clicking on 'unknown' entry will open it in Inspector.
    // No information is lost: if there is an error related
    // to specified hashOrPath user will read it in Inspector.
    const [, , cid] = path.split('/')
    return {
      path: hashOrPath,
      cid: CID.asCID(cid) ?? CID.parse(cid),
      type: 'unknown',
      cumulativeSize: 0,
      size: 0
    }
  }
}
@typedef {Object} Stat
@property {string} path
@property {'file'|'directory'|'unknown'} type
@property {CID} cid
@property {number} cumulativeSize
@property {number} size

@param {IPFSService} ipfs
@param {string|CID} cidOrPath
@returns {Promise<Stat>}