# All files / lib/server/files ls.js

100% Statements 21/21
75% Branches 3/4
100% Functions 6/6
100% Lines 21/21

    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

    1x

    1x
    19x

    3x

    2x

    2x
    2x
    2x
    2x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    1x

    3x'use strict';

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

    exports.default = function (getIpfs, opts) {
      return {
        ls: (0, _postmsgRpc.expose)('ipfs.files.ls', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _cid.preCidFromJson)(0), opts.pre['files.ls'], function () {
          var _getIpfs;

          return (_getIpfs = getIpfs()).ls.apply(_getIpfs, arguments);
        }), opts),
        lsPullStream: (0, _postmsgRpc.expose)('ipfs.files.lsPullStream', (0, _prepost.pre)((0, _buffer.preBufferFromJson)(0), (0, _cid.preCidFromJson)(0), opts.pre['files.lsPullStream'], (0, _prepost.post)(function () {
          var _getIpfs2;

          return (_getIpfs2 = getIpfs()).lsPullStream.apply(_getIpfs2, arguments);
        }, function (res) {
          return new Promise(function (resolve) {
            var readFnName = (0, _shortid2.default)();
            (0, _pullStream2.default)(res, _pullPostmsgStream2.default.sink(readFnName, opts));
            resolve((0, _function.functionToJson)(readFnName));
          });
        })), opts)
      };
    };

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

    var _prepost = require('prepost');

    var _pullStream = require('pull-stream');

    var _pullStream2 = _interopRequireDefault(_pullStream);

    var _pullPostmsgStream = require('pull-postmsg-stream');

    var _pullPostmsgStream2 = _interopRequireDefault(_pullPostmsgStream);

    var _shortid = require('shortid');

    var _shortid2 = _interopRequireDefault(_shortid);

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

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

    var _function = require('../../serialization/function');

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