# All files / lib/serialization buffer.js

100% Statements 22/22
100% Branches 6/6
100% Functions 7/7
100% Lines 22/22

    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

    1x

    1x
    11323x

    1x
    11323x

    1x
    1x
    51441x

    1x
    589x
    11148x
    22202x

    11148x
    11045x

    11148x

    1x
    589x
    11148x
    22202x

    11148x
    11045x

    11148x

     'use strict';

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    var bufferFromJson = exports.bufferFromJson = function bufferFromJson(obj) {
      return Buffer.from(obj.data);
    };

    var bufferToJson = exports.bufferToJson = function bufferToJson(buf) {
      return {
        __ipfsPostMsgProxyType: 'Buffer',
        data: Array.from(buf)
      };
    };

    var isBuffer = exports.isBuffer = Buffer.isBuffer;
    var isBufferJson = exports.isBufferJson = function isBufferJson(obj) {
      return obj && obj.__ipfsPostMsgProxyType === 'Buffer';
    };

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

        if (isBufferJson(args[index])) {
          args[index] = bufferFromJson(args[index]);
        }
        return args;
      };
    };

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

        if (isBuffer(args[index])) {
          args[index] = bufferToJson(args[index]);
        }
        return args;
      };
    };