UNPKG

parse-lcov

Version:
40 lines (30 loc) 1.24 kB
"use strict"; exports.__esModule = true; exports["default"] = parseLCOV; var _line = require("./line"); var _record = require("./record"); exports.LCOVRecord = _record.LCOVRecord; exports.FunctionsDetails = _record.FunctionsDetails; exports.BranchesDetails = _record.BranchesDetails; exports.LinesDetails = _record.LinesDetails; var _transform = require("./transform"); function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function parseLCOV(string) { if (string === void 0) { string = ""; } var lines = string.split("\n"); var record = (0, _record.newRecord)(); return lines.reduce(function (retval, line) { if ((0, _line.isEnd)(line)) { retval.push(_extends({}, record)); record = (0, _record.newRecord)(); } else { var _parseLine = (0, _line.parseLine)(line), type = _parseLine.type, data = _parseLine.data; (0, _transform.transform)(record, type, data); } return retval; }, []); }