# All files / lib/server swarm.js

100% Statements 19/19
100% Branches 0/0
100% Functions 10/10
100% Lines 19/19

    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
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51

    1x

    1x
    19x

    7x

    7x
    7x
    7x
    7x

    2x

    2x

    2x

    2x

    14x

    2x

    1x

    1x

    1x

    1x

    1x'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });

    exports.default = function (getIpfs, opts) {
      return {
        peers: (0, _postmsgRpc.expose)('ipfs.swarm.peers', (0, _prepost.pre)(opts.pre['swarm.peers'], (0, _prepost.post)(function () {
          var _getIpfs$swarm;

          return (_getIpfs$swarm = getIpfs().swarm).peers.apply(_getIpfs$swarm, arguments);
        }, function (res) {
          return res.map(function (item) {
            item.addr = (0, _multiaddr.multiaddrToJson)(item.addr);
            item.peer = (0, _peer.peerInfoToJson)(item.peer);
            return item;
          });
        })), opts),
        addrs: (0, _postmsgRpc.expose)('ipfs.swarm.addrs', (0, _prepost.pre)(opts.pre['swarm.addrs'], (0, _prepost.post)(function () {
          return getIpfs().swarm.addrs();
        }, function (res) {
          return res.map(_peer.peerInfoToJson);
        })), opts),
        localAddrs: (0, _postmsgRpc.expose)('ipfs.swarm.localAddrs', (0, _prepost.pre)(opts.pre['swarm.localAddrs'], (0, _prepost.post)(function () {
          return getIpfs().swarm.localAddrs();
        }, function (res) {
          return res.map(_multiaddr.multiaddrToJson);
        })), opts),
        connect: (0, _postmsgRpc.expose)('ipfs.swarm.connect', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _multiaddr.preMultiaddrFromJson)(0), opts.pre['swarm.connect'], function () {
          var _getIpfs$swarm2;

          return (_getIpfs$swarm2 = getIpfs().swarm).connect.apply(_getIpfs$swarm2, arguments);
        }), opts),
        disconnect: (0, _postmsgRpc.expose)('ipfs.swarm.disconnect', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _multiaddr.preMultiaddrFromJson)(0), opts.pre['swarm.disconnect'], function () {
          var _getIpfs$swarm3;

          return (_getIpfs$swarm3 = getIpfs().swarm).disconnect.apply(_getIpfs$swarm3, arguments);
        }), opts)
      };
    };

    var _postmsgRpc = require('postmsg-rpc');

    var _prepost = require('prepost');

    var _peer = require('../serialization/peer');

    var _multiaddr = require('../serialization/multiaddr');

    var _buffer = require('../serialization/buffer');