From abd94a7f5a50f43c797a11b53549ae48fff667c3 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Mon, 10 Oct 2016 03:43:44 +0200 Subject: add node_modules to address #4364 --- node_modules/istanbul-lib-coverage/.doc.yml | 3 + node_modules/istanbul-lib-coverage/CHANGELOG.md | 11 + node_modules/istanbul-lib-coverage/LICENSE | 24 ++ node_modules/istanbul-lib-coverage/README.md | 32 ++ node_modules/istanbul-lib-coverage/index.js | 64 ++++ .../istanbul-lib-coverage/lib/coverage-map.js | 116 ++++++++ node_modules/istanbul-lib-coverage/lib/file.js | 331 +++++++++++++++++++++ node_modules/istanbul-lib-coverage/package.json | 114 +++++++ 8 files changed, 695 insertions(+) create mode 100644 node_modules/istanbul-lib-coverage/.doc.yml create mode 100644 node_modules/istanbul-lib-coverage/CHANGELOG.md create mode 100644 node_modules/istanbul-lib-coverage/LICENSE create mode 100644 node_modules/istanbul-lib-coverage/README.md create mode 100644 node_modules/istanbul-lib-coverage/index.js create mode 100644 node_modules/istanbul-lib-coverage/lib/coverage-map.js create mode 100644 node_modules/istanbul-lib-coverage/lib/file.js create mode 100644 node_modules/istanbul-lib-coverage/package.json (limited to 'node_modules/istanbul-lib-coverage') diff --git a/node_modules/istanbul-lib-coverage/.doc.yml b/node_modules/istanbul-lib-coverage/.doc.yml new file mode 100644 index 000000000..dbf917bf9 --- /dev/null +++ b/node_modules/istanbul-lib-coverage/.doc.yml @@ -0,0 +1,3 @@ +order: + - Exports + diff --git a/node_modules/istanbul-lib-coverage/CHANGELOG.md b/node_modules/istanbul-lib-coverage/CHANGELOG.md new file mode 100644 index 000000000..12057e61a --- /dev/null +++ b/node_modules/istanbul-lib-coverage/CHANGELOG.md @@ -0,0 +1,11 @@ +# Change Log + +All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + + +# [1.0.0](https://github.com/istanbuljs/istanbul-lib-coverage/compare/v1.0.0-alpha.3...v1.0.0) (2016-08-12) + + +### Bug Fixes + +* guard against missing statement ([76aad99](https://github.com/istanbuljs/istanbul-lib-coverage/commit/76aad99)) diff --git a/node_modules/istanbul-lib-coverage/LICENSE b/node_modules/istanbul-lib-coverage/LICENSE new file mode 100644 index 000000000..d55d2916e --- /dev/null +++ b/node_modules/istanbul-lib-coverage/LICENSE @@ -0,0 +1,24 @@ +Copyright 2012-2015 Yahoo! Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Yahoo! Inc. nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/node_modules/istanbul-lib-coverage/README.md b/node_modules/istanbul-lib-coverage/README.md new file mode 100644 index 000000000..2f893e297 --- /dev/null +++ b/node_modules/istanbul-lib-coverage/README.md @@ -0,0 +1,32 @@ +istanbul-lib-coverage +--------------------- + +[![Build Status](https://travis-ci.org/istanbuljs/istanbul-lib-coverage.svg?branch=master)](https://travis-ci.org/istanbuljs/istanbul-lib-coverage) + +An API that provides a read-only view of coverage information with the ability +to merge and summarize coverage info. + +Supersedes `object-utils` and `collector` from the v0 istanbul API. + +See the docs for the full API. + +```js + +var libCoverage = require('istanbul-lib-coverage'); +var map = libCoverage.createCoverageMap(globalCoverageVar); +var summary = libCoverage.createCoverageSummary(); + +// merge another coverage map into the one we created +map.merge(otherCoverageMap); + +// inspect and summarize all file coverage objects in the map +map.files().forEach(function (f) { + var fc = map.fileCoverageFor(f), + s = fc.toSummary(); + summary.merge(s); +}); + +console.log('Global summary', summary); + +``` + diff --git a/node_modules/istanbul-lib-coverage/index.js b/node_modules/istanbul-lib-coverage/index.js new file mode 100644 index 000000000..e88298213 --- /dev/null +++ b/node_modules/istanbul-lib-coverage/index.js @@ -0,0 +1,64 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +/** + * istanbul-lib-coverage exports an API that allows you to create and manipulate + * file coverage, coverage maps (a set of file coverage objects) and summary + * coverage objects. File coverage for the same file can be merged as can + * entire coverage maps. + * + * @module Exports + */ +var CoverageSummary = require('./lib/file').CoverageSummary, + FileCoverage = require('./lib/file').FileCoverage, + CoverageMap = require('./lib/coverage-map').CoverageMap; + +module.exports = { + /** + * creates a coverage summary object + * @param {Object} obj an argument with the same semantics + * as the one passed to the `CoverageSummary` constructor + * @returns {CoverageSummary} + */ + createCoverageSummary: function (obj) { + if (obj && obj instanceof CoverageSummary) { + return obj; + } + return new CoverageSummary(obj); + }, + /** + * creates a CoverageMap object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the CoverageMap constructor. + * @returns {CoverageMap} + */ + createCoverageMap: function (obj) { + if (obj && obj instanceof CoverageMap) { + return obj; + } + return new CoverageMap(obj); + }, + /** + * creates a FileCoverage object + * @param {Object} obj optional - an argument with the same semantics + * as the one passed to the FileCoverage constructor. + * @returns {FileCoverage} + */ + createFileCoverage: function (obj) { + if (obj && obj instanceof FileCoverage) { + return obj; + } + return new FileCoverage(obj); + } +}; + +/** classes exported for reuse */ +module.exports.classes = { + /** + * the file coverage constructor + */ + FileCoverage: FileCoverage +}; diff --git a/node_modules/istanbul-lib-coverage/lib/coverage-map.js b/node_modules/istanbul-lib-coverage/lib/coverage-map.js new file mode 100644 index 000000000..440779a6a --- /dev/null +++ b/node_modules/istanbul-lib-coverage/lib/coverage-map.js @@ -0,0 +1,116 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +var FileCoverage = require('./file').FileCoverage, + CoverageSummary = require('./file').CoverageSummary; + +function loadMap(source) { + var data = {}; + Object.keys(source).forEach(function (k) { + var cov = source[k]; + if (cov instanceof FileCoverage) { + data[k] = cov; + } else { + data[k] = new FileCoverage(cov); + } + }); + return data; +} +/** + * CoverageMap is a map of `FileCoverage` objects keyed by file paths. + * @param {Object} [obj=undefined] obj A coverage map from which to initialize this + * map's contents. This can be the raw global coverage object. + * @constructor + */ +function CoverageMap(obj) { + if (!obj) { + this.data = {}; + } else if (obj instanceof CoverageMap) { + this.data = obj.data; + } else { + this.data = loadMap(obj); + } +} +/** + * merges a second coverage map into this one + * @param {CoverageMap} obj - a CoverageMap or its raw data. Coverage is merged + * correctly for the same files and additional file coverage keys are created + * as needed. + */ +CoverageMap.prototype.merge = function (obj) { + var that = this, + other; + if (obj instanceof CoverageMap) { + other = obj; + } else { + other = new CoverageMap(obj); + } + Object.keys(other.data).forEach(function (k) { + var fc = other.data[k]; + if (that.data[k]) { + that.data[k].merge(fc); + } else { + that.data[k] = fc; + } + }); +}; +/** + * returns a JSON-serializable POJO for this coverage map + * @returns {Object} + */ +CoverageMap.prototype.toJSON = function () { + return this.data; +}; +/** + * returns an array for file paths for which this map has coverage + * @returns {Array{string}} - array of files + */ +CoverageMap.prototype.files = function () { + return Object.keys(this.data); +}; +/** + * returns the file coverage for the specified file. + * @param {String} file + * @returns {FileCoverage} + */ +CoverageMap.prototype.fileCoverageFor = function (file) { + var fc = this.data[file]; + if (!fc) { + throw new Error('No file coverage available for: ' + file); + } + return fc; +}; +/** + * adds a file coverage object to this map. If the path for the object, + * already exists in the map, it is merged with the existing coverage + * otherwise a new key is added to the map. + * @param {FileCoverage} fc the file coverage to add + */ +CoverageMap.prototype.addFileCoverage = function (fc) { + var cov = new FileCoverage(fc), + path = cov.path; + if (this.data[path]) { + this.data[path].merge(cov); + } else { + this.data[path] = cov; + } +}; +/** + * returns the coverage summary for all the file coverage objects in this map. + * @returns {CoverageSummary} + */ +CoverageMap.prototype.getCoverageSummary = function () { + var that = this, + ret = new CoverageSummary(); + this.files().forEach(function (key) { + ret.merge(that.fileCoverageFor(key).toSummary()); + }); + return ret; +}; + +module.exports = { + CoverageMap: CoverageMap +}; diff --git a/node_modules/istanbul-lib-coverage/lib/file.js b/node_modules/istanbul-lib-coverage/lib/file.js new file mode 100644 index 000000000..0cfb8a4be --- /dev/null +++ b/node_modules/istanbul-lib-coverage/lib/file.js @@ -0,0 +1,331 @@ +/* + Copyright 2012-2015, Yahoo Inc. + Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. + */ +"use strict"; + +function percent(covered, total) { + var tmp; + if (total > 0) { + tmp = 1000 * 100 * covered / total + 5; + return Math.floor(tmp / 10) / 100; + } else { + return 100.00; + } +} + +function blankSummary() { + var empty = function () { + return { + total: 0, + covered: 0, + skipped: 0, + pct: 'Unknown' + }; + }; + return { + lines: empty(), + statements: empty(), + functions: empty(), + branches: empty() + }; +} + +// asserts that a data object "looks like" a summary coverage object +function assertValidSummary(obj) { + var valid = obj && + obj.lines && + obj.statements && + obj.functions && + obj.branches; + if (!valid) { + throw new Error('Invalid summary coverage object, missing keys, found:' + + Object.keys(obj).join(',')); + } +} +/** + * CoverageSummary provides a summary of code coverage . It exposes 4 properties, + * `lines`, `statements`, `branches`, and `functions`. Each of these properties + * is an object that has 4 keys `total`, `covered`, `skipped` and `pct`. + * `pct` is a percentage number (0-100). + * @param {Object|CoverageSummary} [obj=undefined] an optional data object or + * another coverage summary to initialize this object with. + * @constructor + */ +function CoverageSummary(obj) { + if (!obj) { + this.data = blankSummary(); + } else if (obj instanceof CoverageSummary) { + this.data = obj.data; + } else { + this.data = obj; + } + assertValidSummary(this.data); +} + +['lines', 'statements', 'functions', 'branches'].forEach(function (p) { + Object.defineProperty(CoverageSummary.prototype, p, { + enumerable: true, + get: function () { + return this.data[p]; + } + }); +}); + +/** + * merges a second summary coverage object into this one + * @param {CoverageSummary} obj - another coverage summary object + */ +CoverageSummary.prototype.merge = function (obj) { + var that = this, + keys = ['lines', 'statements', 'branches', 'functions']; + keys.forEach(function (key) { + that[key].total += obj[key].total; + that[key].covered += obj[key].covered; + that[key].skipped += obj[key].skipped; + that[key].pct = percent(that[key].covered, that[key].total); + }); + return this; +}; + +/** + * returns a POJO that is JSON serializable. May be used to get the raw + * summary object. + */ +CoverageSummary.prototype.toJSON = function () { + return this.data; +}; + +// returns a data object that represents empty coverage +function emptyCoverage(filePath) { + return { + path: filePath, + statementMap: {}, + fnMap: {}, + branchMap: {}, + s: {}, + f: {}, + b: {} + }; +} +// asserts that a data object "looks like" a coverage object +function assertValidObject(obj) { + var valid = obj && + obj.path && + obj.statementMap && + obj.fnMap && + obj.branchMap && + obj.s && + obj.f && + obj.b; + if (!valid) { + throw new Error('Invalid file coverage object, missing keys, found:' + + Object.keys(obj).join(',')); + } +} +/** + * provides a read-only view of coverage for a single file. + * The deep structure of this object is documented elsewhere. It has the following + * properties: + * + * * `path` - the file path for which coverage is being tracked + * * `statementMap` - map of statement locations keyed by statement index + * * `functionMap` - map of function metadata keyed by function index + * * `branchMap` - map of branch metadata keyed by branch index + * * `s` - hit counts for statements + * * `f` - hit count for functions + * * `b` - hit count for branches + * + * @param {Object|FileCoverage|String} pathOrObj is a string that initializes + * and empty coverage object with the specified file path or a data object that + * has all the required properties for a file coverage object. + * @constructor + */ +function FileCoverage(pathOrObj) { + if (!pathOrObj) { + throw new Error("Coverage must be initialized with a path or an object"); + } + if (typeof pathOrObj === 'string') { + this.data = emptyCoverage(pathOrObj); + } else if (pathOrObj instanceof FileCoverage) { + this.data = pathOrObj.data; + } else if (typeof pathOrObj === 'object') { + this.data = pathOrObj; + } else { + throw new Error('Invalid argument to coverage constructor'); + } + assertValidObject(this.data); +} +/** + * returns computed line coverage from statement coverage. + * This is a map of hits keyed by line number in the source. + */ +FileCoverage.prototype.getLineCoverage = function () { + var statementMap = this.data.statementMap, + statements = this.data.s, + lineMap = {}; + + Object.keys(statements).forEach(function (st) { + if (!statementMap[st]) { + return; + } + var line = statementMap[st].start.line, + count = statements[st], + prevVal = lineMap[line]; + if (prevVal === undefined || prevVal < count) { + lineMap[line] = count; + } + }); + return lineMap; +}; +/** + * returns an array of uncovered line numbers. + * @returns {Array} an array of line numbers for which no hits have been + * collected. + */ +FileCoverage.prototype.getUncoveredLines = function () { + var lc = this.getLineCoverage(), + ret = []; + Object.keys(lc).forEach(function (l) { + var hits = lc[l]; + if (hits === 0) { + ret.push(l); + } + }); + return ret; +}; +/** + * returns a map of branch coverage by source line number. + * @returns {Object} an object keyed by line number. Each object + * has a `covered`, `total` and `coverage` (percentage) property. + */ +FileCoverage.prototype.getBranchCoverageByLine = function () { + var branchMap = this.branchMap, + branches = this.b, + ret = {}; + Object.keys(branchMap).forEach(function (k) { + var line = branchMap[k].line, + branchData = branches[k]; + ret[line] = ret[line] || []; + ret[line].push.apply(ret[line], branchData); + }); + Object.keys(ret).forEach(function (k) { + var dataArray = ret[k], + covered = dataArray.filter(function (item) { return item > 0; }), + coverage = covered.length / dataArray.length * 100; + ret[k] = { covered: covered.length, total: dataArray.length, coverage: coverage }; + }); + return ret; +}; + +// expose coverage data attributes +['path', 'statementMap', 'fnMap', 'branchMap', 's', 'f', 'b' ].forEach(function (p) { + Object.defineProperty(FileCoverage.prototype, p, { + enumerable: true, + get: function () { + return this.data[p]; + } + }); +}); +/** + * return a JSON-serializable POJO for this file coverage object + */ +FileCoverage.prototype.toJSON = function () { + return this.data; +}; +/** + * merges a second coverage object into this one, updating hit counts + * @param {FileCoverage} other - the coverage object to be merged into this one. + * Note that the other object should have the same structure as this one (same file). + */ +FileCoverage.prototype.merge = function (other) { + var that = this; + Object.keys(other.s).forEach(function (k) { + that.data.s[k] += other.s[k]; + }); + Object.keys(other.f).forEach(function (k) { + that.data.f[k] += other.f[k]; + }); + Object.keys(other.b).forEach(function (k) { + var i, + retArray = that.data.b[k], + secondArray = other.b[k]; + for (i = 0; i < retArray.length; i += 1) { + retArray[i] += secondArray[i]; + } + }); +}; + +FileCoverage.prototype.computeSimpleTotals = function (property) { + var stats = this[property], + ret = {total: 0, covered: 0, skipped: 0}; + + if (typeof stats === 'function') { + stats = stats.call(this); + } + Object.keys(stats).forEach(function (key) { + var covered = !!stats[key]; + ret.total += 1; + if (covered) { + ret.covered += 1; + } + }); + ret.pct = percent(ret.covered, ret.total); + return ret; +}; + +FileCoverage.prototype.computeBranchTotals = function () { + var stats = this.b, + ret = {total: 0, covered: 0, skipped: 0}; + + Object.keys(stats).forEach(function (key) { + var branches = stats[key], + covered; + branches.forEach(function (branchHits) { + covered = branchHits > 0; + if (covered) { + ret.covered += 1; + } + }); + ret.total += branches.length; + }); + ret.pct = percent(ret.covered, ret.total); + return ret; +}; +/** + * resets hit counts for all statements, functions and branches + * in this coverage object resulting in zero coverage. + */ +FileCoverage.prototype.resetHits = function () { + var statements = this.s, + functions = this.f, + branches = this.b; + Object.keys(statements).forEach(function (s) { + statements[s] = 0; + }); + Object.keys(functions).forEach(function (f) { + functions[f] = 0; + }); + Object.keys(branches).forEach(function (b) { + var hits = branches[b]; + branches[b] = hits.map(function () { return 0; }); + }); +}; + +/** + * returns a CoverageSummary for this file coverage object + * @returns {CoverageSummary} + */ +FileCoverage.prototype.toSummary = function () { + var ret = {}; + ret.lines = this.computeSimpleTotals('getLineCoverage'); + ret.functions = this.computeSimpleTotals('f', 'fnMap'); + ret.statements = this.computeSimpleTotals('s', 'statementMap'); + ret.branches = this.computeBranchTotals(); + return new CoverageSummary(ret); +}; + +module.exports = { + CoverageSummary: CoverageSummary, + FileCoverage: FileCoverage +}; diff --git a/node_modules/istanbul-lib-coverage/package.json b/node_modules/istanbul-lib-coverage/package.json new file mode 100644 index 000000000..e70e6fab6 --- /dev/null +++ b/node_modules/istanbul-lib-coverage/package.json @@ -0,0 +1,114 @@ +{ + "_args": [ + [ + { + "raw": "istanbul-lib-coverage@^1.0.0", + "scope": null, + "escapedName": "istanbul-lib-coverage", + "name": "istanbul-lib-coverage", + "rawSpec": "^1.0.0", + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "/home/dold/repos/taler/wallet-webex/node_modules/istanbul-lib-instrument" + ] + ], + "_from": "istanbul-lib-coverage@>=1.0.0 <2.0.0", + "_id": "istanbul-lib-coverage@1.0.0", + "_inCache": true, + "_location": "/istanbul-lib-coverage", + "_nodeVersion": "5.1.0", + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/istanbul-lib-coverage-1.0.0.tgz_1470979978048_0.6411592594813555" + }, + "_npmUser": { + "name": "bcoe", + "email": "ben@npmjs.com" + }, + "_npmVersion": "3.10.6", + "_phantomChildren": {}, + "_requested": { + "raw": "istanbul-lib-coverage@^1.0.0", + "scope": null, + "escapedName": "istanbul-lib-coverage", + "name": "istanbul-lib-coverage", + "rawSpec": "^1.0.0", + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/istanbul-lib-instrument" + ], + "_resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.0.tgz", + "_shasum": "c3f9b6d226da12424064cce87fce0fb57fdfa7a2", + "_shrinkwrap": null, + "_spec": "istanbul-lib-coverage@^1.0.0", + "_where": "/home/dold/repos/taler/wallet-webex/node_modules/istanbul-lib-instrument", + "author": { + "name": "Krishnan Anantheswaran", + "email": "kananthmail-github@yahoo.com" + }, + "bugs": { + "url": "https://github.com/istanbuljs/istanbul-lib-coverage/issues" + }, + "dependencies": {}, + "description": "Data library for istanbul coverage objects", + "devDependencies": { + "chai": "^3.0.0", + "coveralls": "^2.11.4", + "istanbul": "^0.4.0", + "jshint": "^2.8.0", + "mocha": "^2.2.5", + "standard-version": "^2.4.0" + }, + "directories": {}, + "dist": { + "shasum": "c3f9b6d226da12424064cce87fce0fb57fdfa7a2", + "tarball": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-1.0.0.tgz" + }, + "gitHead": "6c9c65ed81ce7c0e8b4efa8a4f5d96f02349c5ea", + "homepage": "https://github.com/istanbuljs/istanbul-lib-coverage", + "karmaDeps": { + "browserify-istanbul": "^0.2.1", + "karma": "^0.13.10", + "karma-browserify": "^4.2.1", + "karma-chrome-launcher": "^0.2.0", + "karma-coverage": "^0.4.2", + "karma-mocha": "^0.2.0", + "karma-phantomjs-launcher": "^0.2.0", + "phantomjs": "^1.9.17" + }, + "keywords": [ + "istanbul", + "coverage", + "data" + ], + "license": "BSD-3-Clause", + "main": "index.js", + "maintainers": [ + { + "name": "bcoe", + "email": "ben@npmjs.com" + }, + { + "name": "gotwarlost", + "email": "kananthmail-github@yahoo.com" + } + ], + "name": "istanbul-lib-coverage", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/istanbuljs/istanbul-lib-coverage.git" + }, + "scripts": { + "fast": "mocha test/", + "posttest": "istanbul check-coverage --statements 95 --branches 80", + "pretest": "jshint index.js lib/ test/", + "release": "standard-version", + "test": "istanbul cover -x 'docs/**' --include-all-sources --print=both _mocha -- test/" + }, + "version": "1.0.0" +} -- cgit v1.2.3