# All files / lib/serialization multiaddr.js

92.59% Statements 25/27
75% Branches 9/12
100% Functions 9/9
92.59% Lines 25/27

    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
    52
    53
    54
    55
    56

    1x

    1x

    1x

    1x

    1x

    1x
    28x

    1x
    28x

    1x
    16x

    1x
    16x

    1x
    38x
    16x
    16x

    16x

    16x

    1x
    38x
    16x
    16x

    16x

    16x

     'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.preMultiaddrToJson = exports.preMultiaddrFromJson = exports.isMultiaddrJson = exports.isMultiaddr = exports.multiaddrToJson = exports.multiaddrFromJson = undefined;

    var _multiaddr = require('multiaddr');

    var _multiaddr2 = _interopRequireDefault(_multiaddr);

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

    var multiaddrFromJson = exports.multiaddrFromJson = function multiaddrFromJson(obj) {
      return new _multiaddr2.default(obj.multiaddr);
    };

    var multiaddrToJson = exports.multiaddrToJson = function multiaddrToJson(multiaddr) {
      return {
        __ipfsPostMsgProxyType: 'Multiaddr',
        multiaddr: multiaddr.toString()
      };
    };

    var isMultiaddr = exports.isMultiaddr = function isMultiaddr(obj) {
      return obj && _multiaddr2.default.isMultiaddr(obj);
    };
    var isMultiaddrJson = exports.isMultiaddrJson = function isMultiaddrJson(obj) {
      return obj && obj.__ipfsPostMsgProxyType === 'Multiaddr';
    };

    var preMultiaddrFromJson = exports.preMultiaddrFromJson = function preMultiaddrFromJson(index) {
      return function () {
        for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
          args[_key] = arguments[_key];
        }

        Iif (isMultiaddrJson(args[index])) {
          args[index] = multiaddrFromJson(args[index]);
        }
        return args;
      };
    };

    var preMultiaddrToJson = exports.preMultiaddrToJson = function preMultiaddrToJson(index) {
      return function () {
        for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
          args[_key2] = arguments[_key2];
        }

        Iif (isMultiaddr(args[index])) {
          args[index] = multiaddrToJson(args[index]);
        }
        return args;
      };
    };