wzp
2021-05-13 7d694a9113118daec5be7ac224dab46a3b20f106
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
"use strict";
 
var stringify = require('.');
 
var _require = require('string_decoder'),
    StringDecoder = _require.StringDecoder;
 
module.exports = function (records) {
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  var data = [];
 
  if (Buffer.isBuffer(records)) {
    var decoder = new StringDecoder();
    records = decoder.write(records);
  }
 
  var stringifier = new stringify.Stringifier(options);
 
  stringifier.push = function (record) {
    if (record) {
      data.push(record.toString());
    }
  };
 
  var _iteratorNormalCompletion = true;
  var _didIteratorError = false;
  var _iteratorError = undefined;
 
  try {
    for (var _iterator = records[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
      var record = _step.value;
      stringifier.write(record);
    }
  } catch (err) {
    _didIteratorError = true;
    _iteratorError = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion && _iterator["return"] != null) {
        _iterator["return"]();
      }
    } finally {
      if (_didIteratorError) {
        throw _iteratorError;
      }
    }
  }
 
  stringifier.end();
  return data.join('');
};