# All files / lib/client swarm.js

100% Statements 18/18
75% Branches 3/4
100% Functions 7/7
100% Lines 18/18

    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

    1x

    1x
    19x

    7x
    7x
    7x
    7x
    7x

    2x

    2x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x'use strict';

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

    exports.default = function (opts) {
      return {
        peers: _callbackify2.default.variadic((0, _prepost.post)((0, _postmsgRpc.caller)('ipfs.swarm.peers', opts), function (res) {
          return Promise.all(res.map(function (item) {
            return (0, _peer.peerInfoFromJson)(item.peer).then(function (peerInfo) {
              item.addr = (0, _multiaddr.multiaddrFromJson)(item.addr);
              item.peer = peerInfo;
              return item;
            });
          }));
        })),
        addrs: (0, _callbackify2.default)((0, _prepost.post)((0, _postmsgRpc.caller)('ipfs.swarm.addrs', opts), function (res) {
          return Promise.all(res.map(_peer.peerInfoFromJson));
        })),
        localAddrs: (0, _callbackify2.default)((0, _prepost.post)((0, _postmsgRpc.caller)('ipfs.swarm.localAddrs', opts), function (res) {
          return res.map(_multiaddr.multiaddrFromJson);
        })),
        connect: _callbackify2.default.variadic((0, _prepost.pre)((0, _buffer.preBufferToJson)(0), (0, _multiaddr.preMultiaddrToJson)(0), (0, _postmsgRpc.caller)('ipfs.swarm.connect', opts))),
        disconnect: _callbackify2.default.variadic((0, _prepost.pre)((0, _buffer.preBufferToJson)(0), (0, _multiaddr.preMultiaddrToJson)(0), (0, _postmsgRpc.caller)('ipfs.swarm.disconnect', opts)))
      };
    };

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

    var _callbackify = require('callbackify');

    var _callbackify2 = _interopRequireDefault(_callbackify);

    var _prepost = require('prepost');

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

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

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

    function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }