# All files / server repo.js

20% Statements 3/15
0% Branches 0/8
0% Functions 0/4
20% Lines 3/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    401x
    1x
    1x

     import { expose } from 'postmsg-rpc'
    import { pre, post } from 'prepost'
    import { isBig, bigToJson } from '../serialization/big'

    export default function (getIpfs, opts) {
      return {
        gc: expose('ipfs.repo.gc', pre(
          opts.pre('repo.gc'),
          (...args) => getIpfs().repo.gc(...args)
        ), opts),
        stat: expose('ipfs.repo.stat', pre(
          opts.pre('repo.stat'),
          post(
            (...args) => getIpfs().repo.stat(...args),
            (stats) => {
              if (stats) {
                if (isBig(stats.numObjects)) {
                  stats.numObjects = bigToJson(stats.numObjects)
                }

                if (isBig(stats.repoSize)) {
                  stats.repoSize = bigToJson(stats.repoSize)
                }

                if (isBig(stats.storageMax)) {
                  stats.storageMax = bigToJson(stats.storageMax)
                }
              }

              return stats
            }
          )
        ), opts),
        version: expose('ipfs.repo.version', pre(
          opts.pre('repo.version'),
          () => getIpfs().repo.version()
        ), opts)
      }
    }