# All files / lib/server object.js

95.83% Statements 23/24
100% Branches 4/4
92.31% Functions 12/13
95.83% Lines 23/24

    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
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84

    1x

    1x
    19x

    3x

    31x
    33x

    31x
    20x

    31x

    31x

    7x

    4x

    5x

    5x

    5x

    2x

    2x

    4x

    1x

    1x

    1x

    1x

    1x'use strict';

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

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

          return (_getIpfs$object = getIpfs().object).new.apply(_getIpfs$object, arguments);
        }, _dag.dagNodeToJson)), opts),
        put: (0, _postmsgRpc.expose)('ipfs.object.put', (0, _prepost.pre)((0, _dag.preDagNodeFromJson)(0), (0, _buffer.preBufferFromJson)(0), function () {
          for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
            args[_key] = arguments[_key];
          }

          if (args[0] && (0, _buffer.isBufferJson)(args[0].Data)) {
            args[0].Data = (0, _buffer.bufferFromJson)(args[0].Data);
          }

          return args;
        }, opts.pre['object.put'], (0, _prepost.post)(function () {
          var _getIpfs$object2;

          return (_getIpfs$object2 = getIpfs().object).put.apply(_getIpfs$object2, arguments);
        }, _dag.dagNodeToJson)), opts),
        get: (0, _postmsgRpc.expose)('ipfs.object.get', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _cid.preCidFromJson)(0), opts.pre['object.get'], (0, _prepost.post)(function () {
          var _getIpfs$object3;

          return (_getIpfs$object3 = getIpfs().object).get.apply(_getIpfs$object3, arguments);
        }, _dag.dagNodeToJson)), opts),
        data: (0, _postmsgRpc.expose)('ipfs.object.data', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _cid.preCidFromJson)(0), opts.pre['object.data'], (0, _prepost.post)(function () {
          var _getIpfs$object4;

          return (_getIpfs$object4 = getIpfs().object).data.apply(_getIpfs$object4, arguments);
        }, _buffer.bufferToJson)), opts),
        links: (0, _postmsgRpc.expose)('ipfs.object.links', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _cid.preCidFromJson)(0), opts.pre['object.links'], (0, _prepost.post)(function () {
          var _getIpfs$object5;

          return (_getIpfs$object5 = getIpfs().object).links.apply(_getIpfs$object5, arguments);
        }, function (res) {
          return res.map(_dag.dagLinkToJson);
        })), opts),
        stat: (0, _postmsgRpc.expose)('ipfs.object.stat', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _cid.preCidFromJson)(0), opts.pre['object.stat'], function () {
          var _getIpfs$object6;

          return (_getIpfs$object6 = getIpfs().object).stat.apply(_getIpfs$object6, arguments);
        }), opts),
        patch: {
          addLink: (0, _postmsgRpc.expose)('ipfs.object.patch.addLink', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _cid.preCidFromJson)(0), (0, _dag.preDagLinkFromJson)(1), opts.pre['object.patch.addLink'], (0, _prepost.post)(function () {
            var _getIpfs$object$patch;

            return (_getIpfs$object$patch = getIpfs().object.patch).addLink.apply(_getIpfs$object$patch, arguments);
          }, _dag.dagNodeToJson)), opts),
          rmLink: (0, _postmsgRpc.expose)('ipfs.object.patch.rmLink', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _cid.preCidFromJson)(0), (0, _dag.preDagLinkFromJson)(1), opts.pre['object.patch.rmLink'], (0, _prepost.post)(function () {
            var _getIpfs$object$patch2;

            return (_getIpfs$object$patch2 = getIpfs().object.patch).rmLink.apply(_getIpfs$object$patch2, arguments);
          }, _dag.dagNodeToJson)), opts),
          appendData: (0, _postmsgRpc.expose)('ipfs.object.patch.appendData', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _cid.preCidFromJson)(0), (0, _buffer.preBufferFromJson)(1), opts.pre['object.patch.appendData'], (0, _prepost.post)(function () {
            var _getIpfs$object$patch3;

            return (_getIpfs$object$patch3 = getIpfs().object.patch).appendData.apply(_getIpfs$object$patch3, arguments);
          }, _dag.dagNodeToJson)), opts),
          setData: (0, _postmsgRpc.expose)('ipfs.object.patch.setData', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _cid.preCidFromJson)(0), (0, _buffer.preBufferFromJson)(1), opts.pre['object.patch.setData'], (0, _prepost.post)(function () {
            var _getIpfs$object$patch4;

            return (_getIpfs$object$patch4 = getIpfs().object.patch).setData.apply(_getIpfs$object$patch4, arguments);
          }, _dag.dagNodeToJson)), opts)
        }
      };
    };

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

    var _prepost = require('prepost');

    var _dag = require('../serialization/dag');

    var _cid = require('../serialization/cid');

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