Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typhonjs-escomplex-commons

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typhonjs-escomplex-commons - npm Package Compare versions

Comparing version 0.0.16 to 0.1.0

dist/module/report/AggregateReport.js

42

dist/analyze/AnalyzeError.js

@@ -7,6 +7,18 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _assign = require('babel-runtime/core-js/object/assign');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign2 = _interopRequireDefault(_assign);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _ReportType = require('../types/ReportType');

@@ -18,4 +30,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -34,8 +44,7 @@ * Provides a wrapper for analysis errors stored in the `errors` array for each report type.

function AnalyzeError() {
var severity = arguments.length <= 0 || arguments[0] === undefined ? '<unknown>' : arguments[0];
var message = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
var sourceReport = arguments.length <= 2 || arguments[2] === undefined ? void 0 : arguments[2];
var severity = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '<unknown>';
var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var sourceReport = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : void 0;
(0, _classCallCheck3.default)(this, AnalyzeError);
_classCallCheck(this, AnalyzeError);
/**

@@ -45,3 +54,3 @@ * Provides the line number where the error starts.

*/
this.lineStart = (typeof sourceReport === 'undefined' ? 'undefined' : _typeof(sourceReport)) === 'object' ? sourceReport.lineStart : 0;
this.lineStart = (typeof sourceReport === 'undefined' ? 'undefined' : (0, _typeof3.default)(sourceReport)) === 'object' ? sourceReport.lineStart : 0;

@@ -52,3 +61,3 @@ /**

*/
this.lineEnd = (typeof sourceReport === 'undefined' ? 'undefined' : _typeof(sourceReport)) === 'object' ? sourceReport.lineEnd : 0;
this.lineEnd = (typeof sourceReport === 'undefined' ? 'undefined' : (0, _typeof3.default)(sourceReport)) === 'object' ? sourceReport.lineEnd : 0;

@@ -70,3 +79,3 @@ /**

*/
this.name = (typeof sourceReport === 'undefined' ? 'undefined' : _typeof(sourceReport)) === 'object' ? sourceReport.getName() : '';
this.name = (typeof sourceReport === 'undefined' ? 'undefined' : (0, _typeof3.default)(sourceReport)) === 'object' ? sourceReport.getName() : '';

@@ -77,3 +86,3 @@ /**

*/
this.type = (typeof sourceReport === 'undefined' ? 'undefined' : _typeof(sourceReport)) === 'object' ? sourceReport.type : void 0;
this.type = (typeof sourceReport === 'undefined' ? 'undefined' : (0, _typeof3.default)(sourceReport)) === 'object' ? sourceReport.type : void 0;
}

@@ -90,3 +99,3 @@

_createClass(AnalyzeError, [{
(0, _createClass3.default)(AnalyzeError, [{
key: 'toString',

@@ -106,7 +115,7 @@

/* istanbul ignore if */
if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') {
if ((typeof object === 'undefined' ? 'undefined' : (0, _typeof3.default)(object)) !== 'object') {
throw new TypeError('parse error: \'object\' is not an \'object\'.');
}
var error = Object.assign(new AnalyzeError(), object);
var error = (0, _assign2.default)(new AnalyzeError(), object);

@@ -119,3 +128,2 @@ // Deserialize the associated enum type.

}]);
return AnalyzeError;

@@ -122,0 +130,0 @@ }();

@@ -7,8 +7,32 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _getOwnPropertyNames = require('babel-runtime/core-js/object/get-own-property-names');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _getOwnPropertyNames2 = _interopRequireDefault(_getOwnPropertyNames);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -21,6 +45,6 @@ * Provides the base implementation for all syntax loader plugins which automatically associates member methods

function AbstractSyntaxLoader() {
_classCallCheck(this, AbstractSyntaxLoader);
(0, _classCallCheck3.default)(this, AbstractSyntaxLoader);
}
_createClass(AbstractSyntaxLoader, [{
(0, _createClass3.default)(AbstractSyntaxLoader, [{
key: 'onLoadSyntax',

@@ -39,3 +63,3 @@

try {
for (var _iterator = s_GET_ALL_PROPERTY_NAMES(Object.getPrototypeOf(this))[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
for (var _iterator = (0, _getIterator3.default)(s_GET_ALL_PROPERTY_NAMES((0, _getPrototypeOf2.default)(this))), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var name = _step.value;

@@ -51,3 +75,3 @@

// If an existing syntax exists for the given name then combine the results.
ev.data.syntaxes[name] = Object.assign(_typeof(ev.data.syntaxes[name]) === 'object' ? ev.data.syntaxes[name] : {}, this[name](ev.data.settings));
ev.data.syntaxes[name] = (0, _assign2.default)((0, _typeof3.default)(ev.data.syntaxes[name]) === 'object' ? ev.data.syntaxes[name] : {}, this[name](ev.data.settings));
}

@@ -70,3 +94,2 @@ } catch (err) {

}]);
return AbstractSyntaxLoader;

@@ -90,3 +113,3 @@ }();

do {
Object.getOwnPropertyNames(obj).forEach(function (prop) {
(0, _getOwnPropertyNames2.default)(obj).forEach(function (prop) {
if (props.indexOf(prop) === -1) {

@@ -96,3 +119,3 @@ props.push(prop);

});
obj = Object.getPrototypeOf(obj);
obj = (0, _getPrototypeOf2.default)(obj);
} while (typeof obj !== 'undefined' && obj !== null && !(obj === AbstractSyntaxLoader.prototype));

@@ -99,0 +122,0 @@

@@ -7,4 +7,10 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _TransformFormat = require('../../transform/TransformFormat');

@@ -16,6 +22,4 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Provides several helper methods to work with method oriented data stored as `this.methodAggregate` in `ClassReport` /
* Provides several helper methods to work with method oriented data stored as `this.aggregate` in `ClassReport` /
* `ModuleReport` and directly in `ClassMethodReport` / `ModuleMethodReport`.

@@ -26,27 +30,26 @@ */

* If given assigns the method report to an internal variable. This is used by `ClassReport` and `ModuleReport`
* which stores a `AggregateMethodReport` respectively in `this.methodAggregate`.
* which stores a `AggregateReport` respectively in `this.aggregate`.
*
* @param {AggregateMethodReport} aggregateMethodReport - An AggregateMethodReport to associate with this report.
* @param {AggregateReport} aggregateReport - An AggregateReport to associate with this report.
*/
function AbstractReport() {
var aggregateMethodReport = arguments.length <= 0 || arguments[0] === undefined ? void 0 : arguments[0];
var aggregateReport = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : void 0;
(0, _classCallCheck3.default)(this, AbstractReport);
_classCallCheck(this, AbstractReport);
/**
* Stores any associated `AggregateMethodReport`.
* @type {AggregateMethodReport}
* Stores any associated `AggregateReport`.
* @type {AggregateReport}
*/
this.methodAggregate = aggregateMethodReport;
this.aggregate = aggregateReport;
}
/**
* Returns the associated `AggregateMethodReport` or `this`. Both ClassReport and ModuleReport have an
* `methodAggregate` AggregateMethodReport.
* Returns the associated `AggregateReport` or `this`. Both ClassReport and ModuleReport have an
* `aggregate` AggregateReport.
*
* @returns {AggregateMethodReport}
* @returns {AggregateReport}
*/
_createClass(AbstractReport, [{
(0, _createClass3.default)(AbstractReport, [{
key: 'toFormat',

@@ -65,3 +68,3 @@

value: function toFormat(name) {
var options = arguments.length <= 1 || arguments[1] === undefined ? void 0 : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;

@@ -71,8 +74,7 @@ return _TransformFormat2.default.format(this, name, options);

}, {
key: 'aggregateMethodReport',
key: 'aggregateReport',
get: function get() {
return typeof this.methodAggregate !== 'undefined' ? this.methodAggregate : this;
return typeof this.aggregate !== 'undefined' ? this.aggregate : this;
}
}]);
return AbstractReport;

@@ -79,0 +81,0 @@ }();

@@ -7,4 +7,8 @@ "use strict";

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck");
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -19,3 +23,3 @@ * Provides all the averaged Halstead metric data.

function HalsteadAverage() {
_classCallCheck(this, HalsteadAverage);
(0, _classCallCheck3.default)(this, HalsteadAverage);

@@ -22,0 +26,0 @@ /**

@@ -7,2 +7,10 @@ 'use strict';

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _HalsteadAverage = require('./HalsteadAverage');

@@ -12,48 +20,74 @@

var _ObjectUtil = require('../../../utils/ObjectUtil');
var _ObjectUtil2 = _interopRequireDefault(_ObjectUtil);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Provides all the averaged method metric data.
*/
var MethodAverage =
/**
* Initializes the default averaged method data.
*/
function MethodAverage() {
_classCallCheck(this, MethodAverage);
var MethodAverage = function () {
/**
* Measures the average method cyclomatic complexity of the module / class.
* @type {number}
* Initializes the default averaged method data.
*/
this.cyclomatic = 0;
function MethodAverage() {
(0, _classCallCheck3.default)(this, MethodAverage);
/**
* Measures the average method cyclomatic density of the module / class.
* @type {number}
*/
this.cyclomaticDensity = 0;
/**
* Measures the average method cyclomatic complexity of the module / class.
* @type {number}
*/
this.cyclomatic = 0;
/**
* Stores the averaged Halstead metric data.
* @type {HalsteadData}
*/
this.halstead = new _HalsteadAverage2.default();
/**
* Measures the average method cyclomatic density of the module / class.
* @type {number}
*/
this.cyclomaticDensity = 0;
/**
* Measures the average number of method parameters for the module / class.
* @type {number}
*/
this.params = 0;
/**
* Stores the averaged Halstead metric data.
* @type {HalsteadData}
*/
this.halstead = new _HalsteadAverage2.default();
/**
* Measures the average number of method parameters for the module / class.
* @type {number}
*/
this.paramCount = 0;
/**
* Measures the average source lines of code for the module / class.
* @type {{logical: number, physical: number}}
*/
this.sloc = { logical: 0, physical: 0 };
}
/**
* Measures the average source lines of code for the module / class.
* @type {{logical: number, physical: number}}
* Returns the object accessor list / keys for MethodAverage.
*
* @returns {Array<string>}
*/
this.sloc = { logical: 0, physical: 0 };
};
(0, _createClass3.default)(MethodAverage, [{
key: 'keys',
get: function get() {
return s_AVERAGE_KEYS;
}
}]);
return MethodAverage;
}();
/**
* Defines the default method average accessor list / keys.
* @type {Array<string>}
* @ignore
*/
exports.default = MethodAverage;
var s_AVERAGE_KEYS = _ObjectUtil2.default.getAccessorList(new MethodAverage());
module.exports = exports['default'];

@@ -7,2 +7,10 @@ 'use strict';

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _MethodAverage = require('./MethodAverage');

@@ -12,26 +20,52 @@

var _ObjectUtil = require('../../../utils/ObjectUtil');
var _ObjectUtil2 = _interopRequireDefault(_ObjectUtil);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* Provides all the averaged module metric data.
*/
var ModuleAverage =
/**
* Initializes the default averaged module data.
*/
function ModuleAverage() {
_classCallCheck(this, ModuleAverage);
var ModuleAverage = function () {
/**
* Initializes the default averaged module data.
*/
function ModuleAverage() {
(0, _classCallCheck3.default)(this, ModuleAverage);
this.methodAverage = new _MethodAverage2.default();
this.methodAverage = new _MethodAverage2.default();
/**
* Measures the average method maintainability index for the module / file.
* @type {number}
*/
this.maintainability = 0;
}
/**
* Measures the average method maintainability index for the module / file.
* @type {number}
* Returns the object accessor list / keys for ModuleAverage.
*
* @returns {Array<string>}
*/
this.maintainability = 0;
};
(0, _createClass3.default)(ModuleAverage, [{
key: 'keys',
get: function get() {
return s_AVERAGE_KEYS;
}
}]);
return ModuleAverage;
}();
/**
* Defines the default module average accessor list / keys.
* @type {Array<string>}
* @ignore
*/
exports.default = ModuleAverage;
var s_AVERAGE_KEYS = _ObjectUtil2.default.getAccessorList(new ModuleAverage());
module.exports = exports['default'];

@@ -7,4 +7,22 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _MethodReport2 = require('./MethodReport');

@@ -24,8 +42,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -35,17 +47,39 @@ * Provides the class method report object which stores data pertaining to a single method / function.

var ClassMethodReport = function (_MethodReport) {
_inherits(ClassMethodReport, _MethodReport);
(0, _inherits3.default)(ClassMethodReport, _MethodReport);
function ClassMethodReport() {
_classCallCheck(this, ClassMethodReport);
/**
* Initializes class module method report.
*
* @param {string} name - Name of the method.
* @param {number} paramNames - Array of any associated parameter names.
* @param {number} lineStart - Start line of method.
* @param {number} lineEnd - End line of method.
*/
function ClassMethodReport(name, paramNames, lineStart, lineEnd) {
(0, _classCallCheck3.default)(this, ClassMethodReport);
return _possibleConstructorReturn(this, Object.getPrototypeOf(ClassMethodReport).apply(this, arguments));
}
/**
* Stores the max nested method depth.
* @type {number}
*/
var _this = (0, _possibleConstructorReturn3.default)(this, (ClassMethodReport.__proto__ || (0, _getPrototypeOf2.default)(ClassMethodReport)).call(this, name, paramNames, lineStart, lineEnd));
_createClass(ClassMethodReport, [{
key: 'type',
_this.maxNestedMethodDepth = 0;
/**
* Returns the enum for the report type.
* @returns {CLASS_METHOD}
* Stores all nested method data.
* @type {Array<NestedMethodReport>}
*/
_this.nestedMethods = [];
return _this;
}
/**
* Returns the enum for the report type.
* @returns {CLASS_METHOD}
*/
(0, _createClass3.default)(ClassMethodReport, [{
key: 'type',
get: function get() {

@@ -81,3 +115,2 @@ return _ReportType2.default.CLASS_METHOD;

}]);
return ClassMethodReport;

@@ -84,0 +117,0 @@ }(_MethodReport3.default);

@@ -7,6 +7,34 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _assign = require('babel-runtime/core-js/object/assign');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign2 = _interopRequireDefault(_assign);
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _AbstractReport2 = require('./AbstractReport');

@@ -16,5 +44,5 @@

var _AggregateMethodReport = require('./AggregateMethodReport');
var _AggregateReport = require('./AggregateReport');
var _AggregateMethodReport2 = _interopRequireDefault(_AggregateMethodReport);
var _AggregateReport2 = _interopRequireDefault(_AggregateReport);

@@ -47,10 +75,2 @@ var _ClassMethodReport = require('./ClassMethodReport');

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -62,5 +82,4 @@ * Provides the class report object which stores data pertaining to a single ES6 class.

var ClassReport = function (_AbstractReport) {
_inherits(ClassReport, _AbstractReport);
_createClass(ClassReport, [{
(0, _inherits3.default)(ClassReport, _AbstractReport);
(0, _createClass3.default)(ClassReport, [{
key: 'type',

@@ -80,2 +99,3 @@

* @param {string} name - Name of the class.
* @param {string} superClassName - Name of any associated super class.
* @param {number} lineStart - Start line of class.

@@ -88,8 +108,8 @@ * @param {number} lineEnd - End line of class.

function ClassReport() {
var name = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
var lineStart = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
var lineEnd = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2];
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : void 0;
var superClassName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
var lineStart = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var lineEnd = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
(0, _classCallCheck3.default)(this, ClassReport);
_classCallCheck(this, ClassReport);
/**

@@ -99,3 +119,3 @@ * Stores any analysis errors.

*/
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ClassReport).call(this, new _AggregateMethodReport2.default(lineStart, lineEnd)));
var _this = (0, _possibleConstructorReturn3.default)(this, (ClassReport.__proto__ || (0, _getPrototypeOf2.default)(ClassReport)).call(this, new _AggregateReport2.default(lineStart, lineEnd, 0)));

@@ -123,4 +143,10 @@ _this.errors = [];

/**
* Stores the average class aggregate & method metric data.
* @type {MethodAverage}
*/
_this.aggregateAverage = new _MethodAverage2.default();
/**
* Stores the average method metric data.
* @type {HalsteadAverage}
* @type {MethodAverage}
*/

@@ -134,2 +160,8 @@ _this.methodAverage = new _MethodAverage2.default();

_this.name = name;
/**
* The name of any associated super class.
* @type {string}
*/
_this.superClassName = superClassName;
return _this;

@@ -145,6 +177,6 @@ }

_createClass(ClassReport, [{
(0, _createClass3.default)(ClassReport, [{
key: 'clearErrors',
value: function clearErrors() {
var clearChildren = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
var clearChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;

@@ -178,6 +210,6 @@ this.errors = [];

var options = arguments.length <= 0 || arguments[0] === undefined ? { includeChildren: true, includeReports: false } : arguments[0];
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { includeChildren: true, includeReports: false };
/* istanbul ignore if */
if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') {
if ((typeof options === 'undefined' ? 'undefined' : (0, _typeof3.default)(options)) !== 'object') {
throw new TypeError('getErrors error: \'options\' is not an \'object\'.');

@@ -195,3 +227,3 @@ }

return { error: entry, source: _this2 };
}) : (_ref = []).concat.apply(_ref, _toConsumableArray(this.errors));
}) : (_ref = []).concat.apply(_ref, (0, _toConsumableArray3.default)(this.errors));

@@ -202,19 +234,17 @@ // If `includeChildren` is true then traverse all children reports for errors.

if (options.includeReports) {
(function () {
var _errors;
var _errors;
var childErrors = [];
var childErrors = [];
_this2.methods.forEach(function (report) {
childErrors.push.apply(childErrors, _toConsumableArray(report.getErrors(options)));
});
this.methods.forEach(function (report) {
childErrors.push.apply(childErrors, (0, _toConsumableArray3.default)(report.getErrors(options)));
});
// Add module to object hash.
childErrors.forEach(function (error) {
error.class = _this2;
});
// Add module to object hash.
childErrors.forEach(function (error) {
error.class = _this2;
});
// Push to all module errors.
(_errors = errors).push.apply(_errors, childErrors);
})();
// Push to all module errors.
(_errors = errors).push.apply(_errors, childErrors);
} else {

@@ -224,3 +254,3 @@ this.methods.forEach(function (report) {

(_errors2 = errors).push.apply(_errors2, _toConsumableArray(report.getErrors(options)));
(_errors2 = errors).push.apply(_errors2, (0, _toConsumableArray3.default)(report.getErrors(options)));
});

@@ -231,3 +261,3 @@ }

// If `options.query` is defined then filter errors against the query object.
if (_typeof(options.query) === 'object') {
if ((0, _typeof3.default)(options.query) === 'object') {
errors = errors.filter(function (error) {

@@ -276,7 +306,7 @@ return _ObjectUtil2.default.safeEqual(options.query, error);

/* istanbul ignore if */
if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') {
if ((typeof object === 'undefined' ? 'undefined' : (0, _typeof3.default)(object)) !== 'object') {
throw new TypeError('parse error: \'object\' is not an \'object\'.');
}
var classReport = Object.assign(new ClassReport(), object);
var classReport = (0, _assign2.default)(new ClassReport(), object);

@@ -298,3 +328,2 @@ if (classReport.errors.length > 0) {

}]);
return ClassReport;

@@ -301,0 +330,0 @@ }(_AbstractReport3.default);

@@ -7,6 +7,18 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _isInteger = require('babel-runtime/core-js/number/is-integer');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _isInteger2 = _interopRequireDefault(_isInteger);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _ClassReport = require('../ClassReport');

@@ -26,10 +38,20 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* ModuleScopeControl
*/
var ModuleScopeControl = function () {
/**
* Creates ModuleScopeControl instance with given ModuleReport.
*
* @param {ModuleReport} moduleReport - An associated module report.
*/
function ModuleScopeControl(moduleReport) {
_classCallCheck(this, ModuleScopeControl);
(0, _classCallCheck3.default)(this, ModuleScopeControl);
this._report = moduleReport;
this._anonClassCntr = 1;
this._anonMethodCntr = 1;
/**

@@ -46,2 +68,8 @@ * Stores the current class report scope stack which is lazily created in `createScope`.

this._scopeStackMethod = [];
/**
* Stores the current nested method report scope stack which is lazily created in `createScope`.
* @type {Array<ClassMethodReport|ModuleMethodReport>}
*/
this._scopeStackNestedMethod = [];
}

@@ -58,3 +86,3 @@

* (number) lineEnd - End line of method.
* (number) paramCount - (For method scopes) Number of parameters for method.
* (Array<string>) paramNames - (For method scopes) An array of parameters names for method.
* ```

@@ -66,10 +94,10 @@ *

_createClass(ModuleScopeControl, [{
(0, _createClass3.default)(ModuleScopeControl, [{
key: 'createScope',
value: function createScope() {
var newScope = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var newScope = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var report = void 0;
if ((typeof newScope === 'undefined' ? 'undefined' : _typeof(newScope)) !== 'object') {
if ((typeof newScope === 'undefined' ? 'undefined' : (0, _typeof3.default)(newScope)) !== 'object') {
throw new TypeError('createScope error: \'newScope\' is not an \'object\'.');

@@ -86,7 +114,7 @@ }

if (!Number.isInteger(newScope.lineStart)) {
if (!(0, _isInteger2.default)(newScope.lineStart)) {
throw new TypeError('createScope error: \'newScope.lineStart\' is not an \'integer\'.');
}
if (!Number.isInteger(newScope.lineEnd)) {
if (!(0, _isInteger2.default)(newScope.lineEnd)) {
throw new TypeError('createScope error: \'newScope.lineEnd\' is not an \'integer\'.');

@@ -97,13 +125,23 @@ }

case 'class':
report = new _ClassReport2.default(newScope.name, newScope.lineStart, newScope.lineEnd);
this._report.classes.push(report);
this._scopeStackClass.push(report);
break;
{
// Create a specific anonymous class name if applicable.
var className = newScope.name !== '<anonymous>' ? newScope.name : '<anon class-' + this._anonClassCntr++ + '>';
var superClassName = newScope.superClassName !== '<anonymous>' ? newScope.superClassName : '<anon class-' + this._anonClassCntr++ + '>';
report = new _ClassReport2.default(className, superClassName, newScope.lineStart, newScope.lineEnd);
this._report.classes.push(report);
this._scopeStackClass.push(report);
break;
}
case 'method':
{
if (!Number.isInteger(newScope.paramCount)) {
throw new TypeError('createScope error: \'newScope.paramCount\' is not an \'integer\'.');
if (!Array.isArray(newScope.paramNames)) {
throw new TypeError('createScope error: \'newScope.paramNames\' is not an \'array\'.');
}
// Create a specific anonymous method name if applicable.
var methodName = newScope.name !== '<anonymous>' ? newScope.name : '<anon method-' + this._anonMethodCntr++ + '>';
// If an existing class report / scope exists also push the method to the class report.

@@ -113,6 +151,6 @@ var classReport = this.getCurrentClassReport();

if (classReport) {
report = new _ClassMethodReport2.default(newScope.name, newScope.lineStart, newScope.lineEnd, newScope.paramCount);
report = new _ClassMethodReport2.default(methodName, newScope.paramNames, newScope.lineStart, newScope.lineEnd);
classReport.methods.push(report);
} else {
report = new _ModuleMethodReport2.default(newScope.name, newScope.lineStart, newScope.lineEnd, newScope.paramCount);
report = new _ModuleMethodReport2.default(methodName, newScope.paramNames, newScope.lineStart, newScope.lineEnd);

@@ -177,3 +215,3 @@ // Add this report to the module methods as there is no current class report.

value: function popScope(scope) {
if ((typeof scope === 'undefined' ? 'undefined' : _typeof(scope)) !== 'object') {
if ((typeof scope === 'undefined' ? 'undefined' : (0, _typeof3.default)(scope)) !== 'object') {
throw new TypeError('popScope error: \'scope\' is not an \'object\'.');

@@ -200,3 +238,2 @@ }

}]);
return ModuleScopeControl;

@@ -203,0 +240,0 @@ }();

@@ -7,6 +7,16 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _keys = require('babel-runtime/core-js/object/keys');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _keys2 = _interopRequireDefault(_keys);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -21,3 +31,3 @@ * Provides all Halstead metric data / parameters.

function HalsteadData() {
_classCallCheck(this, HalsteadData);
(0, _classCallCheck3.default)(this, HalsteadData);

@@ -89,3 +99,3 @@ /**

_createClass(HalsteadData, [{
(0, _createClass3.default)(HalsteadData, [{
key: 'reset',

@@ -95,5 +105,5 @@ value: function reset() {

var clearIdentifiers = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0];
var clearIdentifiers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
Object.keys(this).forEach(function (key) {
(0, _keys2.default)(this).forEach(function (key) {
if (typeof _this[key] === 'number') {

@@ -112,3 +122,2 @@ _this[key] = 0;

}]);
return HalsteadData;

@@ -115,0 +124,0 @@ }();

@@ -7,10 +7,38 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _assign = require('babel-runtime/core-js/object/assign');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign2 = _interopRequireDefault(_assign);
var _AggregateMethodReport = require('./AggregateMethodReport');
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _AggregateMethodReport2 = _interopRequireDefault(_AggregateMethodReport);
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _AggregateReport2 = require('./AggregateReport');
var _AggregateReport3 = _interopRequireDefault(_AggregateReport2);
var _AnalyzeError = require('../../analyze/AnalyzeError');

@@ -20,17 +48,13 @@

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _ObjectUtil = require('../../utils/ObjectUtil');
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var _ObjectUtil2 = _interopRequireDefault(_ObjectUtil);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* Provides the method report object which stores data pertaining to a single method / function.
*/
var MethodReport = function (_AggregateMethodRepor) {
_inherits(MethodReport, _AggregateMethodRepor);
var MethodReport = function (_AggregateReport) {
(0, _inherits3.default)(MethodReport, _AggregateReport);

@@ -41,14 +65,13 @@ /**

* @param {string} name - Name of the method.
* @param {number} paramNames - Array of any associated parameter names.
* @param {number} lineStart - Start line of method.
* @param {number} lineEnd - End line of method.
* @param {number} params - Number of parameters for method.
*/
function MethodReport() {
var name = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
var lineStart = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
var lineEnd = arguments.length <= 2 || arguments[2] === undefined ? 0 : arguments[2];
var params = arguments.length <= 3 || arguments[3] === undefined ? 0 : arguments[3];
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : void 0;
var paramNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var lineStart = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var lineEnd = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
(0, _classCallCheck3.default)(this, MethodReport);
_classCallCheck(this, MethodReport);
/**

@@ -58,3 +81,3 @@ * Stores any analysis errors.

*/
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(MethodReport).call(this, lineStart, lineEnd));
var _this = (0, _possibleConstructorReturn3.default)(this, (MethodReport.__proto__ || (0, _getPrototypeOf2.default)(MethodReport)).call(this, lineStart, lineEnd));

@@ -82,6 +105,12 @@ _this.errors = [];

/**
* The number of parameters for the method or report.
* Stores any parameter names.
* @type {Array<string>}
*/
_this.paramNames = paramNames;
/**
* The number of parameters for the method.
* @type {number}
*/
_this.params = params;
_this.paramCount = paramNames.length;
return _this;

@@ -92,13 +121,49 @@ }

* Clears all errors stored in the method report.
*
* @param {boolean} clearChildren - (Optional) If false then nested method errors are not cleared; default (true).
*/
_createClass(MethodReport, [{
(0, _createClass3.default)(MethodReport, [{
key: 'clearErrors',
value: function clearErrors() {
var clearChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
this.errors = [];
if (clearChildren && Array.isArray(this.nestedMethods)) {
this.nestedMethods.forEach(function (report) {
report.clearErrors();
});
}
}
// TODO: Remove? Old implementation
// /**
// * Gets all errors stored in the method report.
// *
// * @param {object} options - Optional parameters.
// * @property {boolean} includeChildren - If false then module errors are not included; default (true).
// * @property {boolean} includeReports - If true then results will be an array of object hashes containing `source`
// * (the source report object of the error) and `error`
// * (an AnalyzeError instance) keys; default (false).
// *
// * @returns {Array<AnalyzeError|{error: AnalyzeError, source: *}>}
// */
// getErrors(options = { includeChildren: true, includeReports: false })
// {
// /* istanbul ignore if */
// if (typeof options !== 'object') { throw new TypeError(`getErrors error: 'options' is not an 'object'.`); }
//
// // By default set includeChildren to true.
// /* istanbul ignore if */
// if (typeof options.includeChildren !== 'boolean') { options.includeChildren = true; }
//
// // If `includeReports` is true then return an object hash with the source and error otherwise return the error.
// return options.includeReports ? this.errors.map((entry) => { return { error: entry, source: this }; }) :
// [].concat(...this.errors);
// }
/**
* Gets all errors stored in the method report.
* Gets all errors stored in the method report and by default any nested methods.
*

@@ -120,6 +185,6 @@ * @param {object} options - Optional parameters.

var options = arguments.length <= 0 || arguments[0] === undefined ? { includeChildren: true, includeReports: false } : arguments[0];
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { includeChildren: true, includeReports: false };
/* istanbul ignore if */
if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') {
if ((typeof options === 'undefined' ? 'undefined' : (0, _typeof3.default)(options)) !== 'object') {
throw new TypeError('getErrors error: \'options\' is not an \'object\'.');

@@ -135,5 +200,42 @@ }

// If `includeReports` is true then return an object hash with the source and error otherwise return the error.
return options.includeReports ? this.errors.map(function (entry) {
var errors = options.includeReports ? this.errors.map(function (entry) {
return { error: entry, source: _this2 };
}) : (_ref = []).concat.apply(_ref, _toConsumableArray(this.errors));
}) : (_ref = []).concat.apply(_ref, (0, _toConsumableArray3.default)(this.errors));
// If `includeChildren` is true then traverse all children reports for errors.
if (options.includeChildren && Array.isArray(this.nestedMethods)) {
// Add class to all children errors.
if (options.includeReports) {
var _errors;
var childErrors = [];
this.nestedMethods.forEach(function (report) {
childErrors.push.apply(childErrors, (0, _toConsumableArray3.default)(report.getErrors(options)));
});
// Add module to object hash.
childErrors.forEach(function (error) {
error.method = _this2;
});
// Push to all module errors.
(_errors = errors).push.apply(_errors, childErrors);
} else {
this.nestedMethods.forEach(function (report) {
var _errors2;
(_errors2 = errors).push.apply(_errors2, (0, _toConsumableArray3.default)(report.getErrors(options)));
});
}
}
// If `options.query` is defined then filter errors against the query object.
if ((0, _typeof3.default)(options.query) === 'object') {
errors = errors.filter(function (error) {
return _ObjectUtil2.default.safeEqual(options.query, error);
});
}
return errors;
}

@@ -167,7 +269,7 @@

/* istanbul ignore if */
if ((typeof jsonObject === 'undefined' ? 'undefined' : _typeof(jsonObject)) !== 'object') {
if ((typeof jsonObject === 'undefined' ? 'undefined' : (0, _typeof3.default)(jsonObject)) !== 'object') {
throw new TypeError('parse error: \'jsonObject\' is not an \'object\'.');
}
var methodReport = Object.assign(targetObject, jsonObject);
var methodReport = (0, _assign2.default)(targetObject, jsonObject);

@@ -180,10 +282,17 @@ if (methodReport.errors.length > 0) {

// TODO unimplemented yet!
// if (methodReport.nestedMethods.length > 0)
// {
// methodReport.nestedMethods = methodReport.nestedMethods.map((method) => NestedMethodReport.parse(method));
// }
return methodReport;
}
}]);
return MethodReport;
}(_AggregateMethodReport2.default);
}(_AggregateReport3.default);
// import NestedMethodReport from './NestedMethodReport';
exports.default = MethodReport;
module.exports = exports['default'];

@@ -7,4 +7,22 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _MethodReport2 = require('./MethodReport');

@@ -24,8 +42,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -35,17 +47,39 @@ * Provides the module method report object which stores data pertaining to a single method / function.

var ModuleMethodReport = function (_MethodReport) {
_inherits(ModuleMethodReport, _MethodReport);
(0, _inherits3.default)(ModuleMethodReport, _MethodReport);
function ModuleMethodReport() {
_classCallCheck(this, ModuleMethodReport);
/**
* Initializes module method report.
*
* @param {string} name - Name of the method.
* @param {number} paramNames - Array of any associated parameter names.
* @param {number} lineStart - Start line of method.
* @param {number} lineEnd - End line of method.
*/
function ModuleMethodReport(name, paramNames, lineStart, lineEnd) {
(0, _classCallCheck3.default)(this, ModuleMethodReport);
return _possibleConstructorReturn(this, Object.getPrototypeOf(ModuleMethodReport).apply(this, arguments));
}
/**
* Stores the max nested method depth.
* @type {number}
*/
var _this = (0, _possibleConstructorReturn3.default)(this, (ModuleMethodReport.__proto__ || (0, _getPrototypeOf2.default)(ModuleMethodReport)).call(this, name, paramNames, lineStart, lineEnd));
_createClass(ModuleMethodReport, [{
key: 'type',
_this.maxNestedMethodDepth = 0;
/**
* Returns the enum for the report type.
* @returns {ReportType}
* Stores all nested method data.
* @type {Array<NestedMethodReport>}
*/
_this.nestedMethods = [];
return _this;
}
/**
* Returns the enum for the report type.
* @returns {ReportType}
*/
(0, _createClass3.default)(ModuleMethodReport, [{
key: 'type',
get: function get() {

@@ -81,3 +115,2 @@ return _ReportType2.default.MODULE_METHOD;

}]);
return ModuleMethodReport;

@@ -84,0 +117,0 @@ }(_MethodReport3.default);

@@ -7,6 +7,34 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _AbstractReport2 = require('./AbstractReport');

@@ -16,5 +44,5 @@

var _AggregateMethodReport = require('./AggregateMethodReport');
var _AggregateReport = require('./AggregateReport');
var _AggregateMethodReport2 = _interopRequireDefault(_AggregateMethodReport);
var _AggregateReport2 = _interopRequireDefault(_AggregateReport);

@@ -55,10 +83,2 @@ var _ClassReport = require('./ClassReport');

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -73,5 +93,4 @@ * Provides the module report object which stores data pertaining to a single file / module being processed.

var ModuleReport = function (_AbstractReport) {
_inherits(ModuleReport, _AbstractReport);
_createClass(ModuleReport, [{
(0, _inherits3.default)(ModuleReport, _AbstractReport);
(0, _createClass3.default)(ModuleReport, [{
key: 'type',

@@ -100,8 +119,7 @@

function ModuleReport() {
var lineStart = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];
var lineEnd = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
var settings = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var lineStart = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var lineEnd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var settings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
(0, _classCallCheck3.default)(this, ModuleReport);
_classCallCheck(this, ModuleReport);
/**

@@ -111,5 +129,5 @@ * Stores the settings used to generate the module report.

*/
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ModuleReport).call(this, new _AggregateMethodReport2.default(lineStart, lineEnd)));
var _this = (0, _possibleConstructorReturn3.default)(this, (ModuleReport.__proto__ || (0, _getPrototypeOf2.default)(ModuleReport)).call(this, new _AggregateReport2.default(lineStart, lineEnd)));
_this.settings = (typeof settings === 'undefined' ? 'undefined' : _typeof(settings)) === 'object' ? Object.assign({}, settings) : {};
_this.settings = (typeof settings === 'undefined' ? 'undefined' : (0, _typeof3.default)(settings)) === 'object' ? (0, _assign2.default)({}, settings) : {};

@@ -153,3 +171,3 @@ /**

/**
* Measures the average method maintainability index for the module / file.
* Measures the average maintainability index for the module / file.
* @type {number}

@@ -166,5 +184,11 @@ */

/**
* Stores the average method metric data.
* Stores the average module / class aggregate & method metric data.
* @type {MethodAverage}
*/
_this.aggregateAverage = new _MethodAverage2.default();
/**
* Stores just the average method metric data.
* @type {MethodAverage}
*/
_this.methodAverage = new _MethodAverage2.default();

@@ -197,6 +221,6 @@

_createClass(ModuleReport, [{
(0, _createClass3.default)(ModuleReport, [{
key: 'clearErrors',
value: function clearErrors() {
var clearChildren = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
var clearChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;

@@ -245,6 +269,6 @@ this.errors = [];

var options = arguments.length <= 0 || arguments[0] === undefined ? { includeChildren: true, includeReports: false } : arguments[0];
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { includeChildren: true, includeReports: false };
/* istanbul ignore if */
if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') {
if ((typeof options === 'undefined' ? 'undefined' : (0, _typeof3.default)(options)) !== 'object') {
throw new TypeError('getErrors error: \'options\' is not an \'object\'.');

@@ -262,3 +286,3 @@ }

return { error: entry, source: _this2 };
}) : (_ref = []).concat.apply(_ref, _toConsumableArray(this.errors));
}) : (_ref = []).concat.apply(_ref, (0, _toConsumableArray3.default)(this.errors));

@@ -269,22 +293,20 @@ // If `includeChildren` is true then traverse all children reports for errors.

if (options.includeReports) {
(function () {
var _errors;
var _errors;
var childErrors = [];
var childErrors = [];
_this2.methods.forEach(function (report) {
childErrors.push.apply(childErrors, _toConsumableArray(report.getErrors(options)));
});
_this2.classes.forEach(function (report) {
childErrors.push.apply(childErrors, _toConsumableArray(report.getErrors(options)));
});
this.methods.forEach(function (report) {
childErrors.push.apply(childErrors, (0, _toConsumableArray3.default)(report.getErrors(options)));
});
this.classes.forEach(function (report) {
childErrors.push.apply(childErrors, (0, _toConsumableArray3.default)(report.getErrors(options)));
});
// Add module to object hash.
childErrors.forEach(function (error) {
error.module = _this2;
});
// Add module to object hash.
childErrors.forEach(function (error) {
error.module = _this2;
});
// Push to all module errors.
(_errors = errors).push.apply(_errors, childErrors);
})();
// Push to all module errors.
(_errors = errors).push.apply(_errors, childErrors);
} else {

@@ -294,3 +316,3 @@ this.methods.forEach(function (report) {

(_errors2 = errors).push.apply(_errors2, _toConsumableArray(report.getErrors(options)));
(_errors2 = errors).push.apply(_errors2, (0, _toConsumableArray3.default)(report.getErrors(options)));
});

@@ -300,3 +322,3 @@ this.classes.forEach(function (report) {

(_errors3 = errors).push.apply(_errors3, _toConsumableArray(report.getErrors(options)));
(_errors3 = errors).push.apply(_errors3, (0, _toConsumableArray3.default)(report.getErrors(options)));
});

@@ -307,3 +329,3 @@ }

// If `options.query` is defined then filter errors against the query object.
if (_typeof(options.query) === 'object') {
if ((0, _typeof3.default)(options.query) === 'object') {
errors = errors.filter(function (error) {

@@ -347,3 +369,3 @@ return _ObjectUtil2.default.safeEqual(options.query, error);

value: function getSetting(key) {
var defaultValue = arguments.length <= 1 || arguments[1] === undefined ? undefined : arguments[1];
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;

@@ -355,3 +377,3 @@ /* istanbul ignore if */

return _typeof(this.settings) === 'object' && typeof this.settings[key] !== 'undefined' ? this.settings[key] : defaultValue;
return (0, _typeof3.default)(this.settings) === 'object' && typeof this.settings[key] !== 'undefined' ? this.settings[key] : defaultValue;
}

@@ -401,7 +423,7 @@

/* istanbul ignore if */
if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') {
if ((typeof object === 'undefined' ? 'undefined' : (0, _typeof3.default)(object)) !== 'object') {
throw new TypeError('parse error: \'object\' is not an \'object\'.');
}
var report = Object.assign(new ModuleReport(), object);
var report = (0, _assign2.default)(new ModuleReport(), object);

@@ -429,3 +451,2 @@ if (report.classes.length > 0) {

}]);
return ModuleReport;

@@ -432,0 +453,0 @@ }(_AbstractReport3.default);

@@ -8,10 +8,14 @@ 'use strict';

exports.default = function () {
var lloc = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];
var cyclomatic = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
var operators = arguments.length <= 2 || arguments[2] === undefined ? void 0 : arguments[2];
var operands = arguments.length <= 3 || arguments[3] === undefined ? void 0 : arguments[3];
var ignoreKeys = arguments.length <= 4 || arguments[4] === undefined ? void 0 : arguments[4];
var newScope = arguments.length <= 5 || arguments[5] === undefined ? void 0 : arguments[5];
var dependencies = arguments.length <= 6 || arguments[6] === undefined ? void 0 : arguments[6];
var lloc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var cyclomatic = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var operators = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : void 0;
var operands = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : void 0;
var ignoreKeys = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : void 0;
var newScope = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : void 0;
var dependencies = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : void 0;
// Do not wrap ignoreKeys in an array if it is `null` or a `function`. For functions this allows Trait evaluation
// via `Trait->valueOf` to return `null` and not `null` wrapped in an `array`.
var ignoreKeysPassthru = ignoreKeys === null || typeof ignoreKeys === 'function';
return {

@@ -22,3 +26,3 @@ lloc: new _Trait2.default('lloc', lloc),

operands: new _HalsteadArray2.default('operands', _TraitUtil2.default.safeArray(operands)),
ignoreKeys: new _Trait2.default('ignoreKeys', _TraitUtil2.default.safeArray(ignoreKeys)),
ignoreKeys: new _Trait2.default('ignoreKeys', ignoreKeysPassthru ? ignoreKeys : _TraitUtil2.default.safeArray(ignoreKeys)),
newScope: new _Trait2.default('newScope', newScope),

@@ -25,0 +29,0 @@ dependencies: new _Trait2.default('dependencies', dependencies)

@@ -7,6 +7,22 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof2 = require('babel-runtime/helpers/typeof');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _typeof3 = _interopRequireDefault(_typeof2);
var _stringify = require('babel-runtime/core-js/json/stringify');
var _stringify2 = _interopRequireDefault(_stringify);
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _TraitHalstead = require('./TraitHalstead');

@@ -18,6 +34,2 @@

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -35,3 +47,3 @@ * Provides a wrapper around an array of Halstead property object hashes which should contain an

function HalsteadArray(metric, data) {
_classCallCheck(this, HalsteadArray);
(0, _classCallCheck3.default)(this, HalsteadArray);

@@ -73,3 +85,3 @@ /* istanbul ignore if */

_createClass(HalsteadArray, [{
(0, _createClass3.default)(HalsteadArray, [{
key: 'forEach',

@@ -127,3 +139,3 @@ value: function forEach(callback, thisArg) {

// all flattened identifier entries to strings as necessary.
return (_ref = []).concat.apply(_ref, _toConsumableArray(filtered.map(function (traitHalstead) {
return (_ref = []).concat.apply(_ref, (0, _toConsumableArray3.default)(filtered.map(function (traitHalstead) {
return traitHalstead.valueOf.apply(traitHalstead, params);

@@ -142,3 +154,3 @@ }))).map(function (entry) {

// Convert any entries to strings as necessary.
return typeof entry !== 'string' ? JSON.stringify(entry) : entry;
return typeof entry !== 'string' ? (0, _stringify2.default)(entry) : entry;
});

@@ -173,6 +185,5 @@ }

get: function get() {
return _typeof(this._data);
return (0, _typeof3.default)(this._data);
}
}]);
return HalsteadArray;

@@ -179,0 +190,0 @@ }();

@@ -7,8 +7,16 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof2 = require('babel-runtime/helpers/typeof');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _typeof3 = _interopRequireDefault(_typeof2);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -25,3 +33,3 @@ * Provides a wrapper around a data field which may be an array, function or other primitive value.

function Trait(metric, data) {
_classCallCheck(this, Trait);
(0, _classCallCheck3.default)(this, Trait);

@@ -55,3 +63,3 @@ /* istanbul ignore if */

_createClass(Trait, [{
(0, _createClass3.default)(Trait, [{
key: 'valueOf',

@@ -98,6 +106,5 @@

get: function get() {
return _typeof(this._data);
return (0, _typeof3.default)(this._data);
}
}]);
return Trait;

@@ -104,0 +111,0 @@ }();

@@ -7,8 +7,16 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof2 = require('babel-runtime/helpers/typeof');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _typeof3 = _interopRequireDefault(_typeof2);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -26,3 +34,3 @@ * Provides a wrapper around a data object hash which should contain an `identifier` field and potentially a `filter`

function TraitHalstead(metric, data) {
_classCallCheck(this, TraitHalstead);
(0, _classCallCheck3.default)(this, TraitHalstead);

@@ -35,3 +43,3 @@ /* istanbul ignore if */

/* istanbul ignore if */
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') {
if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) !== 'object') {
throw new TypeError('ctor error: data is not an `object`.');

@@ -86,3 +94,3 @@ }

_createClass(TraitHalstead, [{
(0, _createClass3.default)(TraitHalstead, [{
key: 'filter',

@@ -143,6 +151,5 @@ value: function filter() {

get: function get() {
return _typeof(this._data);
return (0, _typeof3.default)(this._data);
}
}]);
return TraitHalstead;

@@ -149,0 +156,0 @@ }();

@@ -7,14 +7,25 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof2 = require('babel-runtime/helpers/typeof');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _typeof3 = _interopRequireDefault(_typeof2);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* TraitUtil
*/
var TraitUtil = function () {
function TraitUtil() {
_classCallCheck(this, TraitUtil);
(0, _classCallCheck3.default)(this, TraitUtil);
}
_createClass(TraitUtil, null, [{
(0, _createClass3.default)(TraitUtil, null, [{
key: 'safeArray',

@@ -45,5 +56,5 @@

value: function safeName(object) {
var defaultName = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
var defaultName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
if (object !== null && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.name === 'string' && object.name !== '') {
if (object !== null && (typeof object === 'undefined' ? 'undefined' : (0, _typeof3.default)(object)) === 'object' && typeof object.name === 'string' && object.name !== '') {
return object.name;

@@ -71,5 +82,5 @@ }

value: function safeValue(object) {
var defaultValue = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
if (object !== null && (typeof object === 'undefined' ? 'undefined' : _typeof(object)) === 'object' && typeof object.value === 'string' && object.value !== '') {
if (object !== null && (typeof object === 'undefined' ? 'undefined' : (0, _typeof3.default)(object)) === 'object' && typeof object.value === 'string' && object.value !== '') {
return object.value;

@@ -85,3 +96,2 @@ }

}]);
return TraitUtil;

@@ -88,0 +98,0 @@ }();

@@ -7,6 +7,22 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _TransformFormat = require('../../transform/TransformFormat');

@@ -42,6 +58,2 @@

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -55,3 +67,3 @@ * Provides the default project report object which stores data pertaining to all modules / files contained.

var ProjectReport = function () {
_createClass(ProjectReport, [{
(0, _createClass3.default)(ProjectReport, [{
key: 'type',

@@ -79,7 +91,6 @@

function ProjectReport() {
var moduleReports = arguments.length <= 0 || arguments[0] === undefined ? void 0 : arguments[0];
var settings = arguments.length <= 1 || arguments[1] === undefined ? { serializeModules: true } : arguments[1];
var moduleReports = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : void 0;
var settings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { serializeModules: true };
(0, _classCallCheck3.default)(this, ProjectReport);
_classCallCheck(this, ProjectReport);
/**

@@ -89,3 +100,3 @@ * Stores the settings used to generate the project report.

*/
this.settings = (typeof settings === 'undefined' ? 'undefined' : _typeof(settings)) === 'object' ? Object.assign({}, settings) : { serializeModules: true };
this.settings = (typeof settings === 'undefined' ? 'undefined' : (0, _typeof3.default)(settings)) === 'object' ? (0, _assign2.default)({}, settings) : { serializeModules: true };

@@ -160,6 +171,6 @@ /**

_createClass(ProjectReport, [{
(0, _createClass3.default)(ProjectReport, [{
key: 'clearErrors',
value: function clearErrors() {
var clearChildren = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0];
var clearChildren = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;

@@ -188,5 +199,5 @@ this.errors = [];

value: function finalize() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') {
if ((typeof options === 'undefined' ? 'undefined' : (0, _typeof3.default)(options)) !== 'object') {
throw new TypeError('finalize error: \'options\' is not an \'object\'.');

@@ -234,6 +245,6 @@ }

var options = arguments.length <= 0 || arguments[0] === undefined ? { includeChildren: true, includeReports: false } : arguments[0];
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { includeChildren: true, includeReports: false };
/* istanbul ignore if */
if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') {
if ((typeof options === 'undefined' ? 'undefined' : (0, _typeof3.default)(options)) !== 'object') {
throw new TypeError('getErrors error: \'options\' is not an \'object\'.');

@@ -251,3 +262,3 @@ }

return { error: entry, source: _this };
}) : (_ref = []).concat.apply(_ref, _toConsumableArray(this.errors));
}) : (_ref = []).concat.apply(_ref, (0, _toConsumableArray3.default)(this.errors));

@@ -259,3 +270,3 @@ // If `includeChildren` is true then traverse all children reports for errors.

(_errors = errors).push.apply(_errors, _toConsumableArray(report.getErrors(options)));
(_errors = errors).push.apply(_errors, (0, _toConsumableArray3.default)(report.getErrors(options)));
});

@@ -265,3 +276,3 @@ }

// If `options.query` is defined then filter errors against the query object.
if (_typeof(options.query) === 'object') {
if ((0, _typeof3.default)(options.query) === 'object') {
errors = errors.filter(function (error) {

@@ -305,3 +316,3 @@ return _ObjectUtil2.default.safeEqual(options.query, error);

value: function getSetting(key) {
var defaultValue = arguments.length <= 1 || arguments[1] === undefined ? undefined : arguments[1];
var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;

@@ -313,3 +324,3 @@ /* istanbul ignore if */

return _typeof(this.settings) === 'object' && typeof this.settings[key] !== 'undefined' ? this.settings[key] : defaultValue;
return (0, _typeof3.default)(this.settings) === 'object' && typeof this.settings[key] !== 'undefined' ? this.settings[key] : defaultValue;
}

@@ -367,3 +378,3 @@

value: function toFormat(name) {
var options = arguments.length <= 1 || arguments[1] === undefined ? undefined : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;

@@ -380,6 +391,6 @@ return _TransformFormat2.default.format(this, name, options);

value: function parse(object) {
var options = arguments.length <= 1 || arguments[1] === undefined ? { skipFinalize: false } : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { skipFinalize: false };
/* istanbul ignore if */
if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') {
if ((typeof object === 'undefined' ? 'undefined' : (0, _typeof3.default)(object)) !== 'object') {
throw new TypeError('parse error: \'object\' is not an \'object\'.');

@@ -389,7 +400,7 @@ }

/* istanbul ignore if */
if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') {
if ((typeof options === 'undefined' ? 'undefined' : (0, _typeof3.default)(options)) !== 'object') {
throw new TypeError('parse error: \'options\' is not an \'object\'.');
}
var projectReport = Object.assign(new ProjectReport(), object);
var projectReport = (0, _assign2.default)(new ProjectReport(), object);

@@ -410,3 +421,2 @@ if (projectReport.modules.length > 0) {

}]);
return ProjectReport;

@@ -413,0 +423,0 @@ }();

@@ -7,8 +7,24 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _stringify = require('babel-runtime/core-js/json/stringify');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _stringify2 = _interopRequireDefault(_stringify);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _isInteger = require('babel-runtime/core-js/number/is-integer');
var _isInteger2 = _interopRequireDefault(_isInteger);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -19,6 +35,6 @@ * Provides a format transform for ESComplex report instances converting them to a JSON string.

function FormatJSON() {
_classCallCheck(this, FormatJSON);
(0, _classCallCheck3.default)(this, FormatJSON);
}
_createClass(FormatJSON, [{
(0, _createClass3.default)(FormatJSON, [{
key: 'formatReport',

@@ -37,5 +53,5 @@

value: function formatReport(report) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object' && Number.isInteger(options.spacing) ? JSON.stringify(report, void 0, options.spacing) : JSON.stringify(report);
return (typeof options === 'undefined' ? 'undefined' : (0, _typeof3.default)(options)) === 'object' && (0, _isInteger2.default)(options.spacing) ? (0, _stringify2.default)(report, void 0, options.spacing) : (0, _stringify2.default)(report);
}

@@ -91,3 +107,2 @@

}]);
return FormatJSON;

@@ -94,0 +109,0 @@ }();

@@ -7,6 +7,26 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _stringify = require('babel-runtime/core-js/json/stringify');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _stringify2 = _interopRequireDefault(_stringify);
var _isInteger = require('babel-runtime/core-js/number/is-integer');
var _isInteger2 = _interopRequireDefault(_isInteger);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _ObjectUtil = require('../../../utils/ObjectUtil');

@@ -22,4 +42,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -40,7 +58,11 @@ * Provides a format transform for ESComplex ModuleReport / ProjectReport instances converting them to JSON that

var FormatJSONCheckstyle = function () {
/**
* Initializes
*
* @param {object} thresholds - Defines thresholds.
*/
function FormatJSONCheckstyle() {
var thresholds = arguments.length <= 0 || arguments[0] === undefined ? s_DEFAULT_THRESHOLDS : arguments[0];
var thresholds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : s_DEFAULT_THRESHOLDS;
(0, _classCallCheck3.default)(this, FormatJSONCheckstyle);
_classCallCheck(this, FormatJSONCheckstyle);
this._thresholds = thresholds;

@@ -61,3 +83,3 @@ }

_createClass(FormatJSONCheckstyle, [{
(0, _createClass3.default)(FormatJSONCheckstyle, [{
key: 'formatReport',

@@ -67,3 +89,3 @@ value: function formatReport(report) {

var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -89,3 +111,3 @@ var reports = void 0,

var localOptions = Object.assign({}, this._thresholds, options);
var localOptions = (0, _assign2.default)({}, this._thresholds, options);

@@ -98,3 +120,3 @@ var output = { version: '7.0', file: [] };

return (typeof localOptions === 'undefined' ? 'undefined' : _typeof(localOptions)) === 'object' && Number.isInteger(localOptions.spacing) ? JSON.stringify(output, void 0, localOptions.spacing) : JSON.stringify(output);
return (typeof localOptions === 'undefined' ? 'undefined' : (0, _typeof3.default)(localOptions)) === 'object' && (0, _isInteger2.default)(localOptions.spacing) ? (0, _stringify2.default)(output, void 0, localOptions.spacing) : (0, _stringify2.default)(output);
}

@@ -152,3 +174,3 @@

if (reportsAvailable) {
if (_typeof(options.moduleReport) === 'object') {
if ((0, _typeof3.default)(options.moduleReport) === 'object') {
this._parseErrors(report, options.moduleReport, output.error);

@@ -158,3 +180,3 @@ }

for (var cntr = 0; cntr < report.methods.length; cntr++) {
if (_typeof(options.methodReport) === 'object') {
if ((0, _typeof3.default)(options.methodReport) === 'object') {
this._parseErrors(report.methods[cntr], options.methodReport, output.error);

@@ -167,3 +189,3 @@ }

if (_typeof(options.classReport) === 'object') {
if ((0, _typeof3.default)(options.classReport) === 'object') {
this._parseErrors(classReport, options.classReport, output.error);

@@ -173,3 +195,3 @@ }

for (var cntr2 = 0; cntr2 < classReport.methods.length; cntr2++) {
if (_typeof(options.methodReport) === 'object') {
if ((0, _typeof3.default)(options.methodReport) === 'object') {
this._parseErrors(classReport.methods[cntr2], options.methodReport, output.error);

@@ -183,2 +205,12 @@ }

}
/**
* Parses errors from report
*
* @param {object} sourceObject - A report object
* @param {object} options - Options
* @param {Array} errors - An array to accumulate errors.
* @private
*/
}, {

@@ -289,3 +321,2 @@ key: '_parseErrors',

}]);
return FormatJSONCheckstyle;

@@ -292,0 +323,0 @@ }();

@@ -7,6 +7,26 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _stringify = require('babel-runtime/core-js/json/stringify');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _stringify2 = _interopRequireDefault(_stringify);
var _isInteger = require('babel-runtime/core-js/number/is-integer');
var _isInteger2 = _interopRequireDefault(_isInteger);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _ObjectUtil = require('../../../utils/ObjectUtil');

@@ -22,4 +42,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -30,7 +48,12 @@ * Provides a format transform for ESComplex ModuleReport / ProjectReport instances converting them to JSON with

var FormatJSONMinimal = function () {
/**
* Initializes format.
*
* @param {object} keys - Defines the keys to include in a minimal JSON representation of class / class method /
* module method / module / project reports.
*/
function FormatJSONMinimal() {
var keys = arguments.length <= 0 || arguments[0] === undefined ? s_DEFAULT_KEYS : arguments[0];
var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : s_DEFAULT_KEYS;
(0, _classCallCheck3.default)(this, FormatJSONMinimal);
_classCallCheck(this, FormatJSONMinimal);
this._keys = keys;

@@ -51,8 +74,8 @@ }

_createClass(FormatJSONMinimal, [{
(0, _createClass3.default)(FormatJSONMinimal, [{
key: 'formatReport',
value: function formatReport(report) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var localOptions = Object.assign({}, this._keys, options);
var localOptions = (0, _assign2.default)({}, this._keys, options);

@@ -68,2 +91,3 @@ var output = void 0;

case _ReportType2.default.MODULE_METHOD:
case _ReportType2.default.NESTED_METHOD:
output = this._formatMethod(report, localOptions);

@@ -85,3 +109,3 @@ break;

return (typeof localOptions === 'undefined' ? 'undefined' : _typeof(localOptions)) === 'object' && Number.isInteger(localOptions.spacing) ? JSON.stringify(output, void 0, localOptions.spacing) : JSON.stringify(output);
return (typeof localOptions === 'undefined' ? 'undefined' : (0, _typeof3.default)(localOptions)) === 'object' && (0, _isInteger2.default)(localOptions.spacing) ? (0, _stringify2.default)(output, void 0, localOptions.spacing) : (0, _stringify2.default)(output);
}

@@ -112,2 +136,3 @@

case _ReportType2.default.MODULE:
case _ReportType2.default.NESTED_METHOD:
case _ReportType2.default.PROJECT:

@@ -352,3 +377,2 @@ return true;

}]);
return FormatJSONMinimal;

@@ -355,0 +379,0 @@ }();

@@ -7,6 +7,22 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _stringify = require('babel-runtime/core-js/json/stringify');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _stringify2 = _interopRequireDefault(_stringify);
var _isInteger = require('babel-runtime/core-js/number/is-integer');
var _isInteger2 = _interopRequireDefault(_isInteger);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _ReportType = require('../../../types/ReportType');

@@ -18,4 +34,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -27,6 +41,6 @@ * Provides a format transform for ESComplex ModuleReport / ProjectReport instances converting them to JSON that

function FormatJSONModules() {
_classCallCheck(this, FormatJSONModules);
(0, _classCallCheck3.default)(this, FormatJSONModules);
}
_createClass(FormatJSONModules, [{
(0, _createClass3.default)(FormatJSONModules, [{
key: 'formatReport',

@@ -45,3 +59,3 @@

value: function formatReport(report) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -64,3 +78,3 @@ var output = void 0;

return (typeof options === 'undefined' ? 'undefined' : _typeof(options)) === 'object' && Number.isInteger(options.spacing) ? JSON.stringify(output, void 0, options.spacing) : JSON.stringify(output);
return (typeof options === 'undefined' ? 'undefined' : (0, _typeof3.default)(options)) === 'object' && (0, _isInteger2.default)(options.spacing) ? (0, _stringify2.default)(output, void 0, options.spacing) : (0, _stringify2.default)(output);
}

@@ -173,3 +187,2 @@

}]);
return FormatJSONModules;

@@ -176,0 +189,0 @@ }();

@@ -7,4 +7,26 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _FormatText2 = require('../text/FormatText');

@@ -20,8 +42,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -31,13 +47,19 @@ * Provides a format transform for ModuleReport / ProjectReport instances converting them to a markdown string.

var FormatMarkdown = function (_FormatText) {
_inherits(FormatMarkdown, _FormatText);
(0, _inherits3.default)(FormatMarkdown, _FormatText);
/**
* Initializes markdown format.
*
* @param {object} headers -
* @param {object} keys -
* @param {string} adjacencyFormatName -
* @param {string} visibilityFormatName -
*/
function FormatMarkdown() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var adjacencyFormatName = arguments.length <= 2 || arguments[2] === undefined ? 'markdown-adjacency' : arguments[2];
var visibilityFormatName = arguments.length <= 3 || arguments[3] === undefined ? 'markdown-visibility' : arguments[3];
_classCallCheck(this, FormatMarkdown);
return _possibleConstructorReturn(this, Object.getPrototypeOf(FormatMarkdown).call(this, Object.assign({}, s_DEFAULT_HEADERS, headers), keys, adjacencyFormatName, visibilityFormatName));
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var adjacencyFormatName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'markdown-adjacency';
var visibilityFormatName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'markdown-visibility';
(0, _classCallCheck3.default)(this, FormatMarkdown);
return (0, _possibleConstructorReturn3.default)(this, (FormatMarkdown.__proto__ || (0, _getPrototypeOf2.default)(FormatMarkdown)).call(this, (0, _assign2.default)({}, s_DEFAULT_HEADERS, headers), keys, adjacencyFormatName, visibilityFormatName));
}

@@ -52,3 +74,3 @@

_createClass(FormatMarkdown, [{
(0, _createClass3.default)(FormatMarkdown, [{
key: 'extension',

@@ -71,3 +93,2 @@ get: function get() {

}]);
return FormatMarkdown;

@@ -74,0 +95,0 @@ }(_FormatText3.default);

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _FormatTextAdjacency2 = require('../text/FormatTextAdjacency');

@@ -15,8 +37,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -26,40 +42,43 @@ * Provides a format transform for ModuleReport / ProjectReport instances converting a matrix list into markdown.

var FormatMarkdownAdjacency = function (_FormatTextAdjacency) {
_inherits(FormatMarkdownAdjacency, _FormatTextAdjacency);
(0, _inherits3.default)(FormatMarkdownAdjacency, _FormatTextAdjacency);
function FormatMarkdownAdjacency() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
/**
* Initializes markdown adjacency format.
*
* @param {object} headers -
* @param {object} keys -
*/
function FormatMarkdownAdjacency() {
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, FormatMarkdownAdjacency);
return (0, _possibleConstructorReturn3.default)(this, (FormatMarkdownAdjacency.__proto__ || (0, _getPrototypeOf2.default)(FormatMarkdownAdjacency)).call(this, (0, _assign2.default)({}, s_DEFAULT_HEADERS, headers), keys));
}
_classCallCheck(this, FormatMarkdownAdjacency);
/**
* Gets the file extension.
*
* @returns {string}
*/
return _possibleConstructorReturn(this, Object.getPrototypeOf(FormatMarkdownAdjacency).call(this, Object.assign({}, s_DEFAULT_HEADERS, headers), keys));
}
/**
* Gets the file extension.
*
* @returns {string}
*/
(0, _createClass3.default)(FormatMarkdownAdjacency, [{
key: 'extension',
get: function get() {
return 'md';
}
/**
* Gets the format name.
*
* @returns {string}
*/
_createClass(FormatMarkdownAdjacency, [{
key: 'extension',
get: function get() {
return 'md';
}
/**
* Gets the format name.
*
* @returns {string}
*/
}, {
key: 'name',
get: function get() {
return 'markdown-adjacency';
}
}]);
return FormatMarkdownAdjacency;
}, {
key: 'name',
get: function get() {
return 'markdown-adjacency';
}
}]);
return FormatMarkdownAdjacency;
}(_FormatTextAdjacency3.default);

@@ -78,6 +97,6 @@

var s_DEFAULT_HEADERS = {
entryPrepend: '* ',
entryWrapper: '`',
textHeader: '* Adjacency (dependencies / numerical indices correspond to ProjectReport modules / reports):\n'
entryPrepend: '* ',
entryWrapper: '`',
textHeader: '* Adjacency (dependencies / numerical indices correspond to ProjectReport modules / reports):\n'
};
module.exports = exports['default'];

@@ -7,4 +7,26 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _FormatTextMinimal2 = require('../text/FormatTextMinimal');

@@ -20,8 +42,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -32,11 +48,15 @@ * Provides a format transform for ModuleReport / ProjectReport instances converting them to markdown with

var FormatMarkdownMinimal = function (_FormatTextMinimal) {
_inherits(FormatMarkdownMinimal, _FormatTextMinimal);
(0, _inherits3.default)(FormatMarkdownMinimal, _FormatTextMinimal);
/**
* Initializes minimal markdown format.
*
* @param {object} headers -
* @param {object} keys -
*/
function FormatMarkdownMinimal() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
_classCallCheck(this, FormatMarkdownMinimal);
return _possibleConstructorReturn(this, Object.getPrototypeOf(FormatMarkdownMinimal).call(this, Object.assign({}, s_DEFAULT_HEADERS, headers), keys));
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, FormatMarkdownMinimal);
return (0, _possibleConstructorReturn3.default)(this, (FormatMarkdownMinimal.__proto__ || (0, _getPrototypeOf2.default)(FormatMarkdownMinimal)).call(this, (0, _assign2.default)({}, s_DEFAULT_HEADERS, headers), keys));
}

@@ -51,3 +71,3 @@

_createClass(FormatMarkdownMinimal, [{
(0, _createClass3.default)(FormatMarkdownMinimal, [{
key: 'extension',

@@ -70,3 +90,2 @@ get: function get() {

}]);
return FormatMarkdownMinimal;

@@ -73,0 +92,0 @@ }(_FormatTextMinimal3.default);

@@ -7,4 +7,26 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _FormatTextModules2 = require('../text/FormatTextModules');

@@ -20,8 +42,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -31,11 +47,15 @@ * Provides a format transform for ModuleReport / ProjectReport instances converting them to markdown with just modules.

var FormatMarkdownModules = function (_FormatTextModules) {
_inherits(FormatMarkdownModules, _FormatTextModules);
(0, _inherits3.default)(FormatMarkdownModules, _FormatTextModules);
/**
* Initializes minimal markdown modules format.
*
* @param {object} headers -
* @param {object} keys -
*/
function FormatMarkdownModules() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
_classCallCheck(this, FormatMarkdownModules);
return _possibleConstructorReturn(this, Object.getPrototypeOf(FormatMarkdownModules).call(this, Object.assign({}, s_DEFAULT_HEADERS, headers), keys));
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, FormatMarkdownModules);
return (0, _possibleConstructorReturn3.default)(this, (FormatMarkdownModules.__proto__ || (0, _getPrototypeOf2.default)(FormatMarkdownModules)).call(this, (0, _assign2.default)({}, s_DEFAULT_HEADERS, headers), keys));
}

@@ -50,3 +70,3 @@

_createClass(FormatMarkdownModules, [{
(0, _createClass3.default)(FormatMarkdownModules, [{
key: 'extension',

@@ -69,3 +89,2 @@ get: function get() {

}]);
return FormatMarkdownModules;

@@ -72,0 +91,0 @@ }(_FormatTextModules3.default);

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _FormatTextVisibility2 = require('../text/FormatTextVisibility');

@@ -15,8 +37,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -26,40 +42,43 @@ * Provides a format transform for ModuleReport / ProjectReport instances converting a matrix list into markdown.

var FormatMarkdownVisibility = function (_FormatTextVisibility) {
_inherits(FormatMarkdownVisibility, _FormatTextVisibility);
(0, _inherits3.default)(FormatMarkdownVisibility, _FormatTextVisibility);
function FormatMarkdownVisibility() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
/**
* Initializes visibility markdown format.
*
* @param {object} headers -
* @param {object} keys -
*/
function FormatMarkdownVisibility() {
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, FormatMarkdownVisibility);
return (0, _possibleConstructorReturn3.default)(this, (FormatMarkdownVisibility.__proto__ || (0, _getPrototypeOf2.default)(FormatMarkdownVisibility)).call(this, (0, _assign2.default)({}, s_DEFAULT_HEADERS, headers), keys));
}
_classCallCheck(this, FormatMarkdownVisibility);
/**
* Gets the file extension.
*
* @returns {string}
*/
return _possibleConstructorReturn(this, Object.getPrototypeOf(FormatMarkdownVisibility).call(this, Object.assign({}, s_DEFAULT_HEADERS, headers), keys));
}
/**
* Gets the file extension.
*
* @returns {string}
*/
(0, _createClass3.default)(FormatMarkdownVisibility, [{
key: 'extension',
get: function get() {
return 'md';
}
/**
* Gets the format name.
*
* @returns {string}
*/
_createClass(FormatMarkdownVisibility, [{
key: 'extension',
get: function get() {
return 'md';
}
/**
* Gets the format name.
*
* @returns {string}
*/
}, {
key: 'name',
get: function get() {
return 'markdown-visibility';
}
}]);
return FormatMarkdownVisibility;
}, {
key: 'name',
get: function get() {
return 'markdown-visibility';
}
}]);
return FormatMarkdownVisibility;
}(_FormatTextVisibility3.default);

@@ -78,6 +97,6 @@

var s_DEFAULT_HEADERS = {
entryPrepend: '* ',
entryWrapper: '`',
textHeader: '* Visibility (reverse dependents / numerical indices correspond to ProjectReport modules / reports):\n'
entryPrepend: '* ',
entryWrapper: '`',
textHeader: '* Visibility (reverse dependents / numerical indices correspond to ProjectReport modules / reports):\n'
};
module.exports = exports['default'];

@@ -7,6 +7,24 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _taggedTemplateLiteral2 = require('babel-runtime/helpers/taggedTemplateLiteral');
var _templateObject = _taggedTemplateLiteral(['', ''], ['', '']);
var _taggedTemplateLiteral3 = _interopRequireDefault(_taggedTemplateLiteral2);
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _templateObject = (0, _taggedTemplateLiteral3.default)(['', ''], ['', '']);
var _ObjectUtil = require('../../../utils/ObjectUtil');

@@ -26,8 +44,2 @@

function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -45,7 +57,6 @@ * Provides the base text format transform for ModuleReport / ProjectReport instances.

function AbstractFormatText() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, AbstractFormatText);
_classCallCheck(this, AbstractFormatText);
this._headers = headers;

@@ -67,8 +78,8 @@ this._keys = keys;

_createClass(AbstractFormatText, [{
(0, _createClass3.default)(AbstractFormatText, [{
key: 'formatReport',
value: function formatReport(report) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var localOptions = Object.assign({}, this._keys, options);
var localOptions = (0, _assign2.default)({}, this._keys, options);

@@ -94,2 +105,6 @@ var output = void 0;

case _ReportType2.default.NESTED_METHOD:
output = this._formatMethod(report, localOptions, '', false).replace(/^[\n]/, '');
break;
case _ReportType2.default.PROJECT:

@@ -125,3 +140,3 @@ output = this._formatProject(report, localOptions);

value: function _formatClass(classReport, options) {
var prepend = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];
var prepend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';

@@ -136,3 +151,3 @@ if (!Array.isArray(this._headers.classReport)) {

// Must concatenate class methods so that the initial prepend isn't displayed twice.
return '' + _StringUtil2.default.safeStringsPrependObject.apply(_StringUtil2.default, [prepend, classReport].concat(_toConsumableArray(this._headers.classReport), _toConsumableArray(this._formatEntries(classReport, options.classReport, indent)))) + this._formatMethods(classReport.methods, options, indent2, false);
return '' + _StringUtil2.default.safeStringsPrependObject.apply(_StringUtil2.default, [prepend, classReport].concat((0, _toConsumableArray3.default)(this._headers.classReport), (0, _toConsumableArray3.default)(this._formatEntries(classReport, options.classReport, indent)))) + this._formatMethods(classReport.methods, options, indent2, false);
}

@@ -160,3 +175,3 @@

var prepend = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];
var prepend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';

@@ -192,4 +207,4 @@ if (!Array.isArray(classReports)) {

value: function _formatEntries(report, entries) {
var prepend = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];
var parentPrepend = arguments.length <= 3 || arguments[3] === undefined ? '' : arguments[3];
var prepend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var parentPrepend = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';

@@ -226,24 +241,22 @@ if (!Array.isArray(entries)) {

if (value.length > 0) {
(function () {
// Provides a temporary object to store each array entry via the given accessor.
var temp = {};
// Provides a temporary object to store each array entry via the given accessor.
var temp = {};
value.forEach(function (valueEntry, index) {
// An array with more than one entry must add the parent prepend string to maintain alignment.
if (index > 0) {
result += parentPrepend;
}
value.forEach(function (valueEntry, index) {
// An array with more than one entry must add the parent prepend string to maintain alignment.
if (index > 0) {
result += parentPrepend;
}
// The abbreviated / minimal transform formats will only contain strings defining the accessor lookup
// so this accessor key is used as the description.
if (typeof entry === 'string') {
result += '' + prepend + entryPrepend + entry + ': ' + valueEntry + '\n';
} else {
// Store the entry via the given accessor which is then dereferenced by `safeStringsPrependObject`.
_ObjectUtil2.default.safeSet(temp, accessor, valueEntry);
// The abbreviated / minimal transform formats will only contain strings defining the accessor lookup
// so this accessor key is used as the description.
if (typeof entry === 'string') {
result += '' + prepend + entryPrepend + entry + ': ' + valueEntry + '\n';
} else {
// Store the entry via the given accessor which is then dereferenced by `safeStringsPrependObject`.
_ObjectUtil2.default.safeSet(temp, accessor, valueEntry);
result += _StringUtil2.default.safeStringsPrependObject('' + prepend + entryPrepend, temp, entry);
}
});
})();
result += _StringUtil2.default.safeStringsPrependObject('' + prepend + entryPrepend, temp, entry);
}
});
}

@@ -281,4 +294,4 @@

value: function _formatMethod(methodReport, options) {
var prepend = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];
var isModule = arguments.length <= 3 || arguments[3] === undefined ? true : arguments[3];
var prepend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var isModule = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;

@@ -292,3 +305,3 @@ // Skip processing if there are no headers.

return _StringUtil2.default.safeStringsPrependObject.apply(_StringUtil2.default, [prepend, methodReport].concat(_toConsumableArray(isModule ? this._headers.moduleMethod : this._headers.classMethod), _toConsumableArray(this._formatEntries(methodReport, options.methodReport, indent, prepend))));
return _StringUtil2.default.safeStringsPrependObject.apply(_StringUtil2.default, [prepend, methodReport].concat((0, _toConsumableArray3.default)(isModule ? this._headers.moduleMethod : this._headers.classMethod), (0, _toConsumableArray3.default)(this._formatEntries(methodReport, options.methodReport, indent, prepend))));
}

@@ -318,4 +331,4 @@

var prepend = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];
var isModule = arguments.length <= 3 || arguments[3] === undefined ? true : arguments[3];
var prepend = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
var isModule = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;

@@ -392,5 +405,5 @@ if (!Array.isArray(methodReports)) {

if (reportsAvailable) {
return _StringUtil2.default.safeStringsObject.apply(_StringUtil2.default, [moduleReport].concat(_toConsumableArray(this._headers.moduleReport), _toConsumableArray(this._formatEntries(moduleReport, options.moduleReport, indent)), [this._formatMethods(moduleReport.methods, options, indent, true), this._formatClasses(moduleReport.classes, options, indent)]));
return _StringUtil2.default.safeStringsObject.apply(_StringUtil2.default, [moduleReport].concat((0, _toConsumableArray3.default)(this._headers.moduleReport), (0, _toConsumableArray3.default)(this._formatEntries(moduleReport, options.moduleReport, indent)), [this._formatMethods(moduleReport.methods, options, indent, true), this._formatClasses(moduleReport.classes, options, indent)]));
} else {
return _StringUtil2.default.safeStringsObject.apply(_StringUtil2.default, [moduleReport].concat(_toConsumableArray(this._headers.moduleReport)));
return _StringUtil2.default.safeStringsObject.apply(_StringUtil2.default, [moduleReport].concat((0, _toConsumableArray3.default)(this._headers.moduleReport)));
}

@@ -460,6 +473,5 @@ }

return _StringUtil2.default.safeStringsObject.apply(_StringUtil2.default, [projectReport].concat(_toConsumableArray(this._headers.projectReport), _toConsumableArray(this._formatEntries(projectReport, options.projectReport, indent))));
return _StringUtil2.default.safeStringsObject.apply(_StringUtil2.default, [projectReport].concat((0, _toConsumableArray3.default)(this._headers.projectReport), (0, _toConsumableArray3.default)(this._formatEntries(projectReport, options.projectReport, indent))));
}
}]);
return AbstractFormatText;

@@ -466,0 +478,0 @@ }();

@@ -7,4 +7,14 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _ObjectUtil = require('../../../utils/ObjectUtil');

@@ -20,4 +30,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -41,7 +49,6 @@ * Provides the base text format transform for ProjectReport matrix list entries.

function AbstractTextMatrix() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, AbstractTextMatrix);
_classCallCheck(this, AbstractTextMatrix);
this._headers = headers;

@@ -63,6 +70,6 @@ this._keys = keys;

_createClass(AbstractTextMatrix, [{
(0, _createClass3.default)(AbstractTextMatrix, [{
key: 'formatReport',
value: function formatReport(report) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -116,5 +123,5 @@ switch (report.type) {

value: function _formatProject(projectReport) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var localOptions = Object.assign({}, this._keys, options);
var localOptions = (0, _assign2.default)({}, this._keys, options);

@@ -195,3 +202,2 @@ var matrixList = _ObjectUtil2.default.safeAccess(projectReport, localOptions.matrixList);

}]);
return AbstractTextMatrix;

@@ -198,0 +204,0 @@ }();

@@ -7,6 +7,30 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _get2 = require('babel-runtime/helpers/get');
var _get3 = _interopRequireDefault(_get2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _AbstractFormatText2 = require('./AbstractFormatText');

@@ -30,8 +54,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -41,14 +59,21 @@ * Provides a format transform for ModuleReport / ProjectReport instances converting them to plain text.

var FormatText = function (_AbstractFormatText) {
_inherits(FormatText, _AbstractFormatText);
(0, _inherits3.default)(FormatText, _AbstractFormatText);
/**
* Initializes text format.
*
* @param {object} headers -
* @param {object} keys -
* @param {string} adjacencyFormatName -
* @param {string} visibilityFormatName -
*/
function FormatText() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var adjacencyFormatName = arguments.length <= 2 || arguments[2] === undefined ? 'text-adjacency' : arguments[2];
var visibilityFormatName = arguments.length <= 3 || arguments[3] === undefined ? 'text-visibility' : arguments[3];
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var adjacencyFormatName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'text-adjacency';
var visibilityFormatName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'text-visibility';
(0, _classCallCheck3.default)(this, FormatText);
_classCallCheck(this, FormatText);
var _this = (0, _possibleConstructorReturn3.default)(this, (FormatText.__proto__ || (0, _getPrototypeOf2.default)(FormatText)).call(this, (0, _assign2.default)({}, s_DEFAULT_HEADERS, headers), (0, _assign2.default)({}, s_DEFAULT_KEYS, keys)));
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(FormatText).call(this, Object.assign({}, s_DEFAULT_HEADERS, headers), Object.assign({}, s_DEFAULT_KEYS, keys)));
_this._adjacencyFormatName = adjacencyFormatName;

@@ -66,3 +91,3 @@ _this._visibilityFormatName = visibilityFormatName;

_createClass(FormatText, [{
(0, _createClass3.default)(FormatText, [{
key: 'isSupported',

@@ -84,2 +109,3 @@

case _ReportType2.default.MODULE:
case _ReportType2.default.NESTED_METHOD:
case _ReportType2.default.PROJECT:

@@ -109,7 +135,7 @@ return true;

value: function _formatProject(projectReport) {
var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var output = _get(Object.getPrototypeOf(FormatText.prototype), '_formatProject', this).call(this, projectReport, options);
var output = (0, _get3.default)(FormatText.prototype.__proto__ || (0, _getPrototypeOf2.default)(FormatText.prototype), '_formatProject', this).call(this, projectReport, options);
var localOptions = Object.assign({}, this._keys, options);
var localOptions = (0, _assign2.default)({}, this._keys, options);

@@ -161,3 +187,2 @@ var adjacency = typeof localOptions.adjacency === 'boolean' ? localOptions.adjacency : true;

}]);
return FormatText;

@@ -164,0 +189,0 @@ }(_AbstractFormatText3.default);

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _AbstractTextMatrix2 = require('./AbstractTextMatrix');

@@ -15,8 +37,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -26,52 +42,55 @@ * Provides a format transform for ModuleReport / ProjectReport instances converting a matrix list into plain text.

var FormatTextAdjacency = function (_AbstractTextMatrix) {
_inherits(FormatTextAdjacency, _AbstractTextMatrix);
(0, _inherits3.default)(FormatTextAdjacency, _AbstractTextMatrix);
function FormatTextAdjacency() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
/**
* Initializes text adjacency format.
*
* @param {object} headers -
* @param {object} keys -
*/
function FormatTextAdjacency() {
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, FormatTextAdjacency);
return (0, _possibleConstructorReturn3.default)(this, (FormatTextAdjacency.__proto__ || (0, _getPrototypeOf2.default)(FormatTextAdjacency)).call(this, (0, _assign2.default)({}, s_DEFAULT_HEADERS, headers), (0, _assign2.default)({}, s_DEFAULT_KEYS, keys)));
}
_classCallCheck(this, FormatTextAdjacency);
/**
* Gets the file extension.
*
* @returns {string}
*/
return _possibleConstructorReturn(this, Object.getPrototypeOf(FormatTextAdjacency).call(this, Object.assign({}, s_DEFAULT_HEADERS, headers), Object.assign({}, s_DEFAULT_KEYS, keys)));
}
/**
* Gets the file extension.
*
* @returns {string}
*/
(0, _createClass3.default)(FormatTextAdjacency, [{
key: 'extension',
get: function get() {
return 'txt';
}
/**
* Gets the format name.
*
* @returns {string}
*/
_createClass(FormatTextAdjacency, [{
key: 'extension',
get: function get() {
return 'txt';
}
}, {
key: 'name',
get: function get() {
return 'text-adjacency';
}
/**
* Gets the format name.
*
* @returns {string}
*/
/**
* Gets the format type.
*
* @returns {string}
*/
}, {
key: 'name',
get: function get() {
return 'text-adjacency';
}
/**
* Gets the format type.
*
* @returns {string}
*/
}, {
key: 'type',
get: function get() {
return 'adjacency';
}
}]);
return FormatTextAdjacency;
}, {
key: 'type',
get: function get() {
return 'adjacency';
}
}]);
return FormatTextAdjacency;
}(_AbstractTextMatrix3.default);

@@ -90,3 +109,3 @@

var s_DEFAULT_KEYS = {
matrixList: 'adjacencyList'
matrixList: 'adjacencyList'
};

@@ -100,6 +119,6 @@

var s_DEFAULT_HEADERS = {
entryPrepend: '',
entryWrapper: '',
textHeader: 'Adjacency (dependencies / numerical indices correspond to ProjectReport modules / reports):\n'
entryPrepend: '',
entryWrapper: '',
textHeader: 'Adjacency (dependencies / numerical indices correspond to ProjectReport modules / reports):\n'
};
module.exports = exports['default'];

@@ -7,4 +7,26 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _AbstractFormatText = require('./AbstractFormatText');

@@ -24,8 +46,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -36,11 +52,15 @@ * Provides a format transform for ModuleReport / ProjectReport instances converting them to plain text with just

var FormatTextMinimal = function (_AbstractFormatTest) {
_inherits(FormatTextMinimal, _AbstractFormatTest);
(0, _inherits3.default)(FormatTextMinimal, _AbstractFormatTest);
/**
* Initializes minimal text format.
*
* @param {object} headers -
* @param {object} keys -
*/
function FormatTextMinimal() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
_classCallCheck(this, FormatTextMinimal);
return _possibleConstructorReturn(this, Object.getPrototypeOf(FormatTextMinimal).call(this, Object.assign({}, s_DEFAULT_HEADERS, headers), Object.assign({}, s_DEFAULT_KEYS, keys)));
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, FormatTextMinimal);
return (0, _possibleConstructorReturn3.default)(this, (FormatTextMinimal.__proto__ || (0, _getPrototypeOf2.default)(FormatTextMinimal)).call(this, (0, _assign2.default)({}, s_DEFAULT_HEADERS, headers), (0, _assign2.default)({}, s_DEFAULT_KEYS, keys)));
}

@@ -55,3 +75,3 @@

_createClass(FormatTextMinimal, [{
(0, _createClass3.default)(FormatTextMinimal, [{
key: 'isSupported',

@@ -73,2 +93,3 @@

case _ReportType2.default.MODULE:
case _ReportType2.default.NESTED_METHOD:
case _ReportType2.default.PROJECT:

@@ -111,3 +132,2 @@ return true;

}]);
return FormatTextMinimal;

@@ -114,0 +134,0 @@ }(_AbstractFormatText2.default);

@@ -7,4 +7,26 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _AbstractFormatText = require('./AbstractFormatText');

@@ -24,8 +46,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -36,11 +52,15 @@ * Provides a format transform for ModuleReport / ProjectReport instances converting them to plain text with just

var FormatTextModules = function (_AbstractFormatTest) {
_inherits(FormatTextModules, _AbstractFormatTest);
(0, _inherits3.default)(FormatTextModules, _AbstractFormatTest);
/**
* Initializes text modules format.
*
* @param {object} headers -
* @param {object} keys -
*/
function FormatTextModules() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
_classCallCheck(this, FormatTextModules);
return _possibleConstructorReturn(this, Object.getPrototypeOf(FormatTextModules).call(this, Object.assign({}, s_DEFAULT_HEADERS, headers), keys));
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, FormatTextModules);
return (0, _possibleConstructorReturn3.default)(this, (FormatTextModules.__proto__ || (0, _getPrototypeOf2.default)(FormatTextModules)).call(this, (0, _assign2.default)({}, s_DEFAULT_HEADERS, headers), keys));
}

@@ -55,3 +75,3 @@

_createClass(FormatTextModules, [{
(0, _createClass3.default)(FormatTextModules, [{
key: 'isSupported',

@@ -107,3 +127,2 @@

}]);
return FormatTextModules;

@@ -110,0 +129,0 @@ }(_AbstractFormatText2.default);

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _AbstractTextMatrix2 = require('./AbstractTextMatrix');

@@ -15,8 +37,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**

@@ -26,52 +42,55 @@ * Provides a format transform for ModuleReport / ProjectReport instances converting a matrix list into plain text.

var FormatTextVisibility = function (_AbstractTextMatrix) {
_inherits(FormatTextVisibility, _AbstractTextMatrix);
(0, _inherits3.default)(FormatTextVisibility, _AbstractTextMatrix);
function FormatTextVisibility() {
var headers = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var keys = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
/**
* Initializes text visibility format.
*
* @param {object} headers -
* @param {object} keys -
*/
function FormatTextVisibility() {
var headers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var keys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, FormatTextVisibility);
return (0, _possibleConstructorReturn3.default)(this, (FormatTextVisibility.__proto__ || (0, _getPrototypeOf2.default)(FormatTextVisibility)).call(this, (0, _assign2.default)({}, s_DEFAULT_HEADERS, headers), (0, _assign2.default)({}, s_DEFAULT_KEYS, keys)));
}
_classCallCheck(this, FormatTextVisibility);
/**
* Gets the file extension.
*
* @returns {string}
*/
return _possibleConstructorReturn(this, Object.getPrototypeOf(FormatTextVisibility).call(this, Object.assign({}, s_DEFAULT_HEADERS, headers), Object.assign({}, s_DEFAULT_KEYS, keys)));
}
/**
* Gets the file extension.
*
* @returns {string}
*/
(0, _createClass3.default)(FormatTextVisibility, [{
key: 'extension',
get: function get() {
return 'txt';
}
/**
* Gets the format name.
*
* @returns {string}
*/
_createClass(FormatTextVisibility, [{
key: 'extension',
get: function get() {
return 'txt';
}
}, {
key: 'name',
get: function get() {
return 'text-visibility';
}
/**
* Gets the format name.
*
* @returns {string}
*/
/**
* Gets the format type.
*
* @returns {string}
*/
}, {
key: 'name',
get: function get() {
return 'text-visibility';
}
/**
* Gets the format type.
*
* @returns {string}
*/
}, {
key: 'type',
get: function get() {
return 'visibility';
}
}]);
return FormatTextVisibility;
}, {
key: 'type',
get: function get() {
return 'visibility';
}
}]);
return FormatTextVisibility;
}(_AbstractTextMatrix3.default);

@@ -90,3 +109,3 @@

var s_DEFAULT_KEYS = {
matrixList: 'visibilityList'
matrixList: 'visibilityList'
};

@@ -100,6 +119,6 @@

var s_DEFAULT_HEADERS = {
entryPrepend: '',
entryWrapper: '',
textHeader: 'Visibility (reverse dependents / numerical indices correspond to ProjectReport modules):\n'
entryPrepend: '',
entryWrapper: '',
textHeader: 'Visibility (reverse dependents / numerical indices correspond to ProjectReport modules):\n'
};
module.exports = exports['default'];

@@ -7,6 +7,26 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _from = require('babel-runtime/core-js/array/from');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _from2 = _interopRequireDefault(_from);
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _map = require('babel-runtime/core-js/map');
var _map2 = _interopRequireDefault(_map);
var _FormatJSON = require('./formats/json/FormatJSON');

@@ -74,4 +94,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -82,10 +100,14 @@ * Stores all transform formats.

*/
var s_FORMATTERS = new Map();
var s_FORMATTERS = new _map2.default();
/**
* TransformFormat
*/
var TransformFormat = function () {
function TransformFormat() {
_classCallCheck(this, TransformFormat);
(0, _classCallCheck3.default)(this, TransformFormat);
}
_createClass(TransformFormat, null, [{
(0, _createClass3.default)(TransformFormat, null, [{
key: 'addFormat',

@@ -99,3 +121,3 @@

value: function addFormat(format) {
if ((typeof format === 'undefined' ? 'undefined' : _typeof(format)) !== 'object') {
if ((typeof format === 'undefined' ? 'undefined' : (0, _typeof3.default)(format)) !== 'object') {
throw new TypeError('addFormat error: \'format\' is not an \'object\'.');

@@ -137,3 +159,3 @@ }

value: function forEach(callback) {
var thisArg = arguments.length <= 1 || arguments[1] === undefined ? void 0 : arguments[1];
var thisArg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;

@@ -155,3 +177,3 @@ s_FORMATTERS.forEach(callback, thisArg);

value: function forEachExt(extension, callback) {
var thisArg = arguments.length <= 2 || arguments[2] === undefined ? void 0 : arguments[2];
var thisArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : void 0;
var _iteratorNormalCompletion = true;

@@ -162,3 +184,3 @@ var _didIteratorError = false;

try {
for (var _iterator = s_FORMATTERS.values()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
for (var _iterator = (0, _getIterator3.default)(s_FORMATTERS.values()), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var format = _step.value;

@@ -198,3 +220,3 @@

value: function forEachType(type, callback) {
var thisArg = arguments.length <= 2 || arguments[2] === undefined ? void 0 : arguments[2];
var thisArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : void 0;
var _iteratorNormalCompletion2 = true;

@@ -205,3 +227,3 @@ var _didIteratorError2 = false;

try {
for (var _iterator2 = s_FORMATTERS.values()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
for (var _iterator2 = (0, _getIterator3.default)(s_FORMATTERS.values()), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var format = _step2.value;

@@ -244,3 +266,3 @@

value: function format(report, name) {
var options = arguments.length <= 2 || arguments[2] === undefined ? void 0 : arguments[2];
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : void 0;

@@ -258,2 +280,3 @@ var formatter = s_FORMATTERS.get(name);

case _ReportType2.default.MODULE:
case _ReportType2.default.NESTED_METHOD:
case _ReportType2.default.PROJECT:

@@ -278,7 +301,7 @@ return formatter.formatReport(report, options);

value: function getFormats() {
var reportType = arguments.length <= 0 || arguments[0] === undefined ? void 0 : arguments[0];
var reportType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : void 0;
// Return all file extensions
if (typeof reportType === 'undefined') {
return Array.from(s_FORMATTERS.values());
return (0, _from2.default)(s_FORMATTERS.values());
}

@@ -291,3 +314,3 @@

// Return a filtered array of formats that are supported by the given ReportType.
return Array.from(s_FORMATTERS.values()).filter(function (format) {
return (0, _from2.default)(s_FORMATTERS.values()).filter(function (format) {
return format.isSupported(reportType);

@@ -343,3 +366,2 @@ });

}]);
return TransformFormat;

@@ -346,0 +368,0 @@ }();

@@ -7,2 +7,18 @@ 'use strict';

var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _Enum2 = require('../utils/Enum');

@@ -14,15 +30,11 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/**
* Defines ReportType enum.
*/
var ReportType = function (_Enum) {
_inherits(ReportType, _Enum);
(0, _inherits3.default)(ReportType, _Enum);
function ReportType() {
_classCallCheck(this, ReportType);
return _possibleConstructorReturn(this, Object.getPrototypeOf(ReportType).apply(this, arguments));
(0, _classCallCheck3.default)(this, ReportType);
return (0, _possibleConstructorReturn3.default)(this, (ReportType.__proto__ || (0, _getPrototypeOf2.default)(ReportType)).apply(this, arguments));
}

@@ -41,4 +53,5 @@

MODULE: { description: 'Module' },
NESTED_METHOD: { description: 'Nested Method' },
PROJECT: { description: 'Project' }
});
module.exports = exports['default'];
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -15,23 +21,39 @@ * Defines the output data from parsing an AST tree.

var ASTData = function () {
function ASTData() {
_classCallCheck(this, ASTData);
/**
* Initializes ASTData
*/
function ASTData() {
(0, _classCallCheck3.default)(this, ASTData);
this.source = '';
this.operands = [];
this.operators = [];
}
this.source = '';
this.operands = [];
this.operators = [];
}
_createClass(ASTData, [{
key: 'write',
value: function write(string) {
this.source += string;
}
}, {
key: 'toString',
value: function toString() {
return this.source;
}
}]);
/**
* Appends a string.
*
* @param {string} string - A string to append.
*/
return ASTData;
(0, _createClass3.default)(ASTData, [{
key: 'write',
value: function write(string) {
this.source += string;
}
/**
* Convert to string
*
* @returns {string|*|string}
*/
}, {
key: 'toString',
value: function toString() {
return this.source;
}
}]);
return ASTData;
}();

@@ -38,0 +60,0 @@

@@ -7,4 +7,14 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _isInteger = require('babel-runtime/core-js/number/is-integer');
var _isInteger2 = _interopRequireDefault(_isInteger);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _ASTData = require('./ASTData');

@@ -20,4 +30,5 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* ASTState
*/
var ASTState =

@@ -33,7 +44,6 @@ /**

function ASTState() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
(0, _classCallCheck3.default)(this, ASTState);
_classCallCheck(this, ASTState);
if ((typeof options === 'undefined' ? 'undefined' : _typeof(options)) !== 'object') {
if ((typeof options === 'undefined' ? 'undefined' : (0, _typeof3.default)(options)) !== 'object') {
throw new TypeError('ctor error: \'options\' is not an \'object\'.');

@@ -52,3 +62,3 @@ }

this.indentLevel = Number.isInteger(options.startingIndentLevel) ? options.startingIndentLevel : 0;
this.indentLevel = (0, _isInteger2.default)(options.startingIndentLevel) ? options.startingIndentLevel : 0;

@@ -55,0 +65,0 @@ // Internal state

@@ -7,2 +7,6 @@ 'use strict';

var _stringify = require('babel-runtime/core-js/json/stringify');
var _stringify2 = _interopRequireDefault(_stringify);
var _ASTUtil = require('./ASTUtil');

@@ -26,4 +30,4 @@

Program: function Program(node, state) {
var lineEnd = state.lineEnd;
var output = state.output;
var lineEnd = state.lineEnd,
output = state.output;

@@ -44,4 +48,4 @@ var indent = state.indent.repeat(state.indentLevel);

BlockStatement: function BlockStatement(node, state) {
var lineEnd = state.lineEnd;
var output = state.output;
var lineEnd = state.lineEnd,
output = state.output;

@@ -158,4 +162,4 @@ var indent = state.indent.repeat(state.indentLevel++);

SwitchStatement: function SwitchStatement(node, state) {
var lineEnd = state.lineEnd;
var output = state.output;
var lineEnd = state.lineEnd,
output = state.output;

@@ -337,5 +341,5 @@ var indent = state.indent.repeat(state.indentLevel++);

var left = node.left;var type = left.type;
var left = node.left,
type = left.type;
state.noTrailingSemicolon = true;

@@ -540,5 +544,5 @@

var specifiers = node.specifiers;var length = specifiers.length;
var specifiers = node.specifiers,
length = specifiers.length;
if (length > 0) {

@@ -691,4 +695,4 @@ for (var i = 0;;) {

var output = state.output;
var quasis = node.quasis;
var expressions = node.expressions;
var quasis = node.quasis,
expressions = node.expressions;
var length = expressions.length;

@@ -727,5 +731,5 @@

if (node.elements.length > 0) {
var elements = node.elements;var length = elements.length;
var elements = node.elements,
length = elements.length;
for (var i = 0;;) {

@@ -740,5 +744,7 @@ var element = elements[i];

output.write(', ');
output.operators.push(',');
} else {
if (element == null) {
output.write(', ');
output.operators.push(',');
}

@@ -756,4 +762,4 @@ break;

ObjectExpression: function ObjectExpression(node, state) {
var lineEnd = state.lineEnd;
var output = state.output;
var lineEnd = state.lineEnd,
output = state.output;

@@ -769,5 +775,6 @@ var indent = state.indent.repeat(state.indentLevel++);

var comma = ',' + lineEnd;var properties = node.properties;var length = properties.length;
var comma = ',' + lineEnd,
properties = node.properties,
length = properties.length;
for (var i = 0;;) {

@@ -796,3 +803,3 @@ var property = properties[i];

Property: function Property(node, state) {
if (node.method || node.kind[0] !== 'i') {
if (node.method || node.kind && node.kind[0] !== 'i') {
this.MethodDefinition(node, state); // Either a method or of kind `set` or `get` (not `init`)

@@ -830,5 +837,5 @@ } else {

if (node.properties.length > 0) {
var properties = node.properties;var length = properties.length;
var properties = node.properties,
length = properties.length;
for (var i = 0;;) {

@@ -1051,3 +1058,3 @@ this.Property(properties[i], state);

} else {
state.output.write(JSON.stringify(node.value));
state.output.write((0, _stringify2.default)(node.value));
}

@@ -1059,3 +1066,3 @@ },

state.output.write('new RegExp(' + JSON.stringify(regex.pattern) + ', ' + JSON.stringify(regex.flags) + ')');
state.output.write('new RegExp(' + (0, _stringify2.default)(regex.pattern) + ', ' + (0, _stringify2.default)(regex.flags) + ')');
},

@@ -1068,7 +1075,7 @@

state.output.write(node.value);
state.output.operands.push(node.value);
state.output.operands.push((0, _stringify2.default)(node.value));
},
DirectiveLiteral: function DirectiveLiteral(node, state) {
state.output.write(node.value);
state.output.operands.push(node.value);
state.output.operands.push((0, _stringify2.default)(node.value));
},

@@ -1081,3 +1088,3 @@ NullLiteral: function NullLiteral(node, state) {

state.output.write(node.value);
state.output.operands.push(node.value);
state.output.operands.push((0, _stringify2.default)(node.value));
},

@@ -1089,4 +1096,4 @@ StringLiteral: function StringLiteral(node, state) {

} else {
state.output.write(JSON.stringify(node.value));
state.output.operands.push(JSON.stringify(node.value));
state.output.write((0, _stringify2.default)(node.value));
state.output.operands.push((0, _stringify2.default)(node.value));
}

@@ -1093,0 +1100,0 @@ }

@@ -7,6 +7,14 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof2 = require('babel-runtime/helpers/typeof');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _expressionPrecedence = require('./expressionPrecedence');

@@ -22,10 +30,11 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**
* ASTUTil
*/
var ASTUtil = function () {
function ASTUtil() {
_classCallCheck(this, ASTUtil);
(0, _classCallCheck3.default)(this, ASTUtil);
}
_createClass(ASTUtil, null, [{
(0, _createClass3.default)(ASTUtil, null, [{
key: 'formatSequence',

@@ -116,5 +125,5 @@

value: function hasCallExpression(node) {
while ((typeof node === 'undefined' ? 'undefined' : _typeof(node)) === 'object') {
var _node = node;
var type = _node.type;
while ((typeof node === 'undefined' ? 'undefined' : (0, _typeof3.default)(node)) === 'object') {
var _node = node,
type = _node.type;

@@ -132,3 +141,2 @@

}]);
return ASTUtil;

@@ -135,0 +143,0 @@ }();

@@ -7,8 +7,48 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _getOwnPropertyDescriptor = require('babel-runtime/core-js/object/get-own-property-descriptor');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _getOwnPropertyDescriptor2 = _interopRequireDefault(_getOwnPropertyDescriptor);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _getOwnPropertyNames = require('babel-runtime/core-js/object/get-own-property-names');
var _getOwnPropertyNames2 = _interopRequireDefault(_getOwnPropertyNames);
var _symbol = require('babel-runtime/core-js/symbol');
var _symbol2 = _interopRequireDefault(_symbol);
var _iterator4 = require('babel-runtime/core-js/symbol/iterator');
var _iterator5 = _interopRequireDefault(_iterator4);
var _defineProperty = require('babel-runtime/core-js/object/define-property');
var _defineProperty2 = _interopRequireDefault(_defineProperty);
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _freeze = require('babel-runtime/core-js/object/freeze');
var _freeze2 = _interopRequireDefault(_freeze);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -31,6 +71,5 @@ * This is an abstract class that is not intended to be used directly. Extend it to turn your class into an enum

function Enum() {
var instanceProperties = arguments.length <= 0 || arguments[0] === undefined ? void 0 : arguments[0];
var instanceProperties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : void 0;
(0, _classCallCheck3.default)(this, Enum);
_classCallCheck(this, Enum);
// new.target would be better than this.constructor, but isn’t supported by Babel

@@ -41,3 +80,3 @@ if ({}.hasOwnProperty.call(this.constructor, INITIALIZED)) {

if ((typeof instanceProperties === 'undefined' ? 'undefined' : _typeof(instanceProperties)) === 'object' && instanceProperties !== null) {
if ((typeof instanceProperties === 'undefined' ? 'undefined' : (0, _typeof3.default)(instanceProperties)) === 'object' && instanceProperties !== null) {
s_COPY_PROPERTIES(this, instanceProperties);

@@ -58,3 +97,3 @@ }

_createClass(Enum, [{
(0, _createClass3.default)(Enum, [{
key: 'toString',

@@ -87,3 +126,3 @@

Object.freeze(this.enumValues);
(0, _freeze2.default)(this.enumValues);
this[INITIALIZED] = true;

@@ -93,2 +132,10 @@

}
/**
* Extracts enum values from an array.
*
* @param {Array} arr -
* @private
*/
}, {

@@ -102,3 +149,3 @@ key: '_enumValuesFromArray',

try {
for (var _iterator = arr[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
for (var _iterator = (0, _getIterator3.default)(arr), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var key = _step.value;

@@ -122,2 +169,10 @@ this._pushEnumValue(new this(), key);

}
/**
* Extracts enum values from an object.
*
* @param {object} obj -
* @private
*/
}, {

@@ -131,3 +186,3 @@ key: '_enumValuesFromObject',

try {
for (var _iterator2 = Object.keys(obj)[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
for (var _iterator2 = (0, _getIterator3.default)((0, _keys2.default)(obj)), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var key = _step2.value;

@@ -153,2 +208,11 @@

}
/**
* Pushes enum value.
*
* @param {object} enumValue -
* @param {string} name -
* @private
*/
}, {

@@ -160,3 +224,3 @@ key: '_pushEnumValue',

Object.defineProperty(this, name, {
(0, _defineProperty2.default)(this, name, {
value: enumValue,

@@ -194,8 +258,7 @@ configurable: false,

}, {
key: Symbol.iterator,
key: _iterator5.default,
value: function value() {
return this.enumValues[Symbol.iterator]();
return (0, _getIterator3.default)(this.enumValues);
}
}]);
return Enum;

@@ -214,3 +277,3 @@ }();

exports.default = Enum;
var INITIALIZED = Symbol();
var INITIALIZED = (0, _symbol2.default)();

@@ -233,7 +296,7 @@ /**

try {
for (var _iterator3 = Object.getOwnPropertyNames(source)[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
for (var _iterator3 = (0, _getIterator3.default)((0, _getOwnPropertyNames2.default)(source)), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var key = _step3.value;
var desc = Object.getOwnPropertyDescriptor(source, key);
Object.defineProperty(target, key, desc);
var desc = (0, _getOwnPropertyDescriptor2.default)(source, key);
(0, _defineProperty2.default)(target, key, desc);
}

@@ -240,0 +303,0 @@ } catch (err) {

@@ -7,4 +7,14 @@ 'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _isInteger = require('babel-runtime/core-js/number/is-integer');
var _isInteger2 = _interopRequireDefault(_isInteger);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _ObjectUtil = require('./ObjectUtil');

@@ -16,4 +26,2 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -24,6 +32,6 @@ * Provides common math utilities.

function MathUtil() {
_classCallCheck(this, MathUtil);
(0, _classCallCheck3.default)(this, MathUtil);
}
_createClass(MathUtil, null, [{
(0, _createClass3.default)(MathUtil, null, [{
key: 'compactMatrix',

@@ -43,3 +51,3 @@

value: function compactMatrix(matrix) {
var testValue = arguments.length <= 1 || arguments[1] === undefined ? 1 : arguments[1];
var testValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;

@@ -77,4 +85,4 @@ var compacted = [];

value: function create2DArray() {
var length = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0];
var value = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
var length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;

@@ -149,3 +157,3 @@ var array = new Array(length);

value: function toFixedTraverse(data) {
return _ObjectUtil2.default.depthTraverse(data, MathUtil.toFixed);
return _ObjectUtil2.default.depthTraverse(data, MathUtil.toFixed, true);
}

@@ -165,6 +173,5 @@

value: function toFixed(val) {
return typeof val === 'number' && !Number.isInteger(val) ? Math.round(val * 1000) / 1000 : val;
return typeof val === 'number' && !(0, _isInteger2.default)(val) ? Math.round(val * 1000) / 1000 : val;
}
}]);
return MathUtil;

@@ -171,0 +178,0 @@ }();

@@ -7,17 +7,50 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _set = require('babel-runtime/core-js/set');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _set2 = _interopRequireDefault(_set);
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _stringify = require('babel-runtime/core-js/json/stringify');
var _stringify2 = _interopRequireDefault(_stringify);
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _isInteger = require('babel-runtime/core-js/number/is-integer');
var _isInteger2 = _interopRequireDefault(_isInteger);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
exports.onPluginLoad = onPluginLoad;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Provides common object manipulation utilities.
* Provides common object manipulation utilities including depth traversal, obtaining accessors, safely setting values /
* equality tests, and validation.
*
* Support for typhonjs-plugin-manager is enabled.
*/
var ObjectUtil = function () {
function ObjectUtil() {
_classCallCheck(this, ObjectUtil);
(0, _classCallCheck3.default)(this, ObjectUtil);
}
_createClass(ObjectUtil, null, [{
(0, _createClass3.default)(ObjectUtil, null, [{
key: 'depthTraverse',

@@ -30,9 +63,15 @@

* @param {object|Array} data - An object or array.
*
* @param {function} func - A callback function to process leaf values in children arrays or object members.
*
* @param {boolean} modify - If true then the result of the callback function is used to modify in place
* the given data.
*
* @returns {*}
*/
value: function depthTraverse(data, func) {
var modify = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
/* istanbul ignore if */
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') {
if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) !== 'object') {
throw new TypeError('depthTraverse error: \'data\' is not an \'object\'.');

@@ -46,3 +85,3 @@ }

return _depthTraverse(data, func);
return _depthTraverse(data, func, modify);
}

@@ -61,3 +100,3 @@

value: function getAccessorList(data) {
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') {
if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) !== 'object') {
throw new TypeError('getAccessorList error: \'data\' is not an \'object\'.');

@@ -75,3 +114,5 @@ }

* @param {object} data - An object to access entry data.
*
* @param {string} accessor - A string describing the entries to access.
*
* @param {*} defaultValue - (Optional) A default value to return if an entry for accessor is not found.

@@ -85,5 +126,5 @@ *

value: function safeAccess(data, accessor) {
var defaultValue = arguments.length <= 2 || arguments[2] === undefined ? void 0 : arguments[2];
var defaultValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : void 0;
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') {
if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) !== 'object') {
return defaultValue;

@@ -111,2 +152,51 @@ }

/**
* Provides a way to safely batch set an objects data / entries given an array of accessor strings which describe the
* entries to walk. To access deeper entries into the object format the accessor string with `.` between entries
* to walk. If value is an object the accessor will be used to access a target value from `value` which is
* subsequently set to `data` by the given operation. If `value` is not an object it will be used as the target
* value to set across all accessors.
*
* @param {object} data - An object to access entry data.
*
* @param {Array<string>} accessors - A string describing the entries to access.
*
* @param {object|*} value - A new value to set if an entry for accessor is found.
*
* @param {string} [operation='set'] - Operation to perform including: 'add', 'div', 'mult', 'set',
* 'set-undefined', 'sub'.
*
* @param {object|*} [defaultAccessValue=0] - A new value to set if an entry for accessor is found.
*
*
* @param {boolean} [createMissing=true] - If true missing accessor entries will be created as objects
* automatically.
*/
}, {
key: 'safeBatchSet',
value: function safeBatchSet(data, accessors, value) {
var operation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'set';
var defaultAccessValue = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
var createMissing = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) !== 'object') {
throw new TypeError('safeBatchSet Error: \'data\' is not an \'object\'.');
}
if (!Array.isArray(accessors)) {
throw new TypeError('safeBatchSet Error: \'accessors\' is not an \'array\'.');
}
if ((typeof value === 'undefined' ? 'undefined' : (0, _typeof3.default)(value)) === 'object') {
accessors.forEach(function (accessor) {
var targetValue = ObjectUtil.safeAccess(value, accessor, defaultAccessValue);
ObjectUtil.safeSet(data, accessor, targetValue, operation, createMissing);
});
} else {
accessors.forEach(function (accessor) {
ObjectUtil.safeSet(data, accessor, value, operation, createMissing);
});
}
}
/**
* Compares a source object and values of entries against a target object. If the entries in the source object match

@@ -117,2 +207,3 @@ * the target object then `true` is returned otherwise `false`. If either object is undefined or null then false

* @param {object} source - Source object.
*
* @param {object} target - Target object.

@@ -152,7 +243,13 @@ *

* @param {object} data - An object to access entry data.
*
* @param {string} accessor - A string describing the entries to access.
*
* @param {*} value - A new value to set if an entry for accessor is found.
* @param {string} operation - (Optional) Operation to perform including: 'add', 'div', 'mult', 'set', 'sub';
* default (`set`).
*
* @param {string} [operation='set'] - Operation to perform including: 'add', 'div', 'mult', 'set',
* 'set-undefined', 'sub'.
*
* @param {boolean} [createMissing=true] - If true missing accessor entries will be created as objects
* automatically.
*
* @returns {boolean} True if successful.

@@ -164,5 +261,6 @@ */

value: function safeSet(data, accessor, value) {
var operation = arguments.length <= 3 || arguments[3] === undefined ? 'set' : arguments[3];
var operation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'set';
var createMissing = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object') {
if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) !== 'object') {
throw new TypeError('safeSet Error: \'data\' is not an \'object\'.');

@@ -178,5 +276,9 @@ }

for (var cntr = 0; cntr < access.length; cntr++) {
// If the next level of object access is undefined then create a new object entry.
if (typeof data[access[cntr]] === 'undefined') {
data[access[cntr]] = {};
// If data is an array perform validation that the accessor is a positive integer otherwise quit.
if (Array.isArray(data)) {
var number = +access[cntr];
if (!(0, _isInteger2.default)(number) || number < 0) {
return false;
}
}

@@ -202,2 +304,8 @@

case 'set-undefined':
if (typeof data[access[cntr]] === 'undefined') {
data[access[cntr]] = value;
}
break;
case 'sub':

@@ -208,4 +316,9 @@ data[access[cntr]] -= value;

} else {
// If createMissing is true and the next level of object access is undefined then create a new object entry.
if (createMissing && typeof data[access[cntr]] === 'undefined') {
data[access[cntr]] = {};
}
// Abort if the next level is null or not an object and containing a value.
if (data[access[cntr]] === null || _typeof(data[access[cntr]]) !== 'object') {
if (data[access[cntr]] === null || (0, _typeof3.default)(data[access[cntr]]) !== 'object') {
return false;

@@ -220,15 +333,435 @@ }

}
/**
* Performs bulk setting of values to the given data object.
*
* @param {object} data - The data object to set data.
*
* @param {object<string, *>} accessorValues - Object of accessor keys to values to set.
*
* @param {string} [operation='set'] - Operation to perform including: 'add', 'div', 'mult', 'set', 'sub';
* default (`set`).
*
* @param {boolean} [createMissing=true] - If true missing accessor entries will be created as objects
* automatically.
*/
}, {
key: 'safeSetAll',
value: function safeSetAll(data, accessorValues) {
var operation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'set';
var createMissing = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) !== 'object') {
throw new TypeError('\'data\' is not an \'object\'.');
}
if ((typeof accessorValues === 'undefined' ? 'undefined' : (0, _typeof3.default)(accessorValues)) !== 'object') {
throw new TypeError('\'accessorValues\' is not an \'object\'.');
}
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = (0, _getIterator3.default)((0, _keys2.default)(accessorValues)), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var accessor = _step.value;
if (!accessorValues.hasOwnProperty(accessor)) {
continue;
}
ObjectUtil.safeSet(data, accessor, accessorValues[accessor], operation, createMissing);
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
/**
* Performs bulk validation of data given an object, `validationData`, which describes all entries to test.
*
* @param {object} data - The data object to test.
*
* @param {object<string, ValidationEntry>} validationData - Key is the accessor / value is a validation entry.
*
* @param {string} [dataName='data'] - Optional name of data.
*
* @returns {boolean} True if validation passes otherwise an exception is thrown.
*/
}, {
key: 'validate',
value: function validate(data) {
var validationData = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var dataName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'data';
if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) !== 'object') {
throw new TypeError('\'' + dataName + '\' is not an \'object\'.');
}
if ((typeof validationData === 'undefined' ? 'undefined' : (0, _typeof3.default)(validationData)) !== 'object') {
throw new TypeError('\'validationData\' is not an \'object\'.');
}
var result = void 0;
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = (0, _getIterator3.default)((0, _keys2.default)(validationData)), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var key = _step2.value;
if (!validationData.hasOwnProperty(key)) {
continue;
}
var entry = validationData[key];
switch (entry.test) {
case 'array':
result = ObjectUtil.validateArray(data, key, entry, dataName);
break;
case 'entry':
result = ObjectUtil.validateEntry(data, key, entry, dataName);
break;
case 'entry|array':
result = ObjectUtil.validateEntryOrArray(data, key, entry, dataName);
break;
}
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return result;
}
// TODO: add docs after upgrading to latest WebStorm / better object destructuring support.
// /**
// * Validates all array entries against potential type and expected tests.
// *
// * @param {object} data - The data object to test.
// *
// * @param {string} accessor - A string describing the entries to access.
// *
// * @param {string} [type] - Tests with a typeof check.
// *
// * @param {function|Set<*>} [expected] - Optional function or set of expected values to test against.
// *
// * @param {string} [message] - Optional message to include.
// *
// * @param {boolean} [required] - When false if the accessor is missing validation is skipped.
// *
// * @param {boolean} [error=true] - When true and error is thrown otherwise a boolean is returned.
// *
// * @param {string} [dataName='data'] - Optional name of data.
// *
// * @returns {boolean} True if validation passes otherwise an exception is thrown.
// */
}, {
key: 'validateArray',
value: function validateArray(data, accessor) {
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
_ref$type = _ref.type,
type = _ref$type === undefined ? void 0 : _ref$type,
_ref$expected = _ref.expected,
expected = _ref$expected === undefined ? void 0 : _ref$expected,
_ref$message = _ref.message,
message = _ref$message === undefined ? void 0 : _ref$message,
_ref$required = _ref.required,
required = _ref$required === undefined ? true : _ref$required,
_ref$error = _ref.error,
error = _ref$error === undefined ? true : _ref$error;
var dataName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'data';
var dataArray = ObjectUtil.safeAccess(data, accessor);
// A non-required entry is missing so return without validation.
if (!required && typeof dataArray === 'undefined') {
return true;
}
if (!Array.isArray(dataArray)) {
if (error) {
throw _validateError(TypeError, '\'' + dataName + '.' + accessor + '\' is not an \'array\'.');
} else {
return false;
}
}
if (typeof type === 'string') {
for (var cntr = 0; cntr < dataArray.length; cntr++) {
if (!((0, _typeof3.default)(dataArray[cntr]) === type)) {
if (error) {
var dataEntryString = (0, _typeof3.default)(dataArray[cntr]) === 'object' ? (0, _stringify2.default)(dataArray[cntr]) : dataArray[cntr];
throw _validateError(TypeError, '\'' + dataName + '.' + accessor + '[' + cntr + ']\': \'' + dataEntryString + '\' is not a \'' + type + '\'.');
} else {
return false;
}
}
}
}
// If expected is a function then test all array entries against the test function. If expected is a Set then
// test all array entries for inclusion in the set. Otherwise if expected is a string then test that all array
// entries as a `typeof` test against expected.
if (Array.isArray(expected)) {
for (var _cntr = 0; _cntr < dataArray.length; _cntr++) {
if (expected.indexOf(dataArray[_cntr]) < 0) {
if (error) {
var _dataEntryString = (0, _typeof3.default)(dataArray[_cntr]) === 'object' ? (0, _stringify2.default)(dataArray[_cntr]) : dataArray[_cntr];
throw _validateError(Error, '\'' + dataName + '.' + accessor + '[' + _cntr + ']\': \'' + _dataEntryString + '\' is not an expected value: ' + (0, _stringify2.default)(expected) + '.');
} else {
return false;
}
}
}
} else if (expected instanceof _set2.default) {
for (var _cntr2 = 0; _cntr2 < dataArray.length; _cntr2++) {
if (!expected.has(dataArray[_cntr2])) {
if (error) {
var _dataEntryString2 = (0, _typeof3.default)(dataArray[_cntr2]) === 'object' ? (0, _stringify2.default)(dataArray[_cntr2]) : dataArray[_cntr2];
throw _validateError(Error, '\'' + dataName + '.' + accessor + '[' + _cntr2 + ']\': \'' + _dataEntryString2 + '\' is not an expected value: ' + (0, _stringify2.default)(expected) + '.');
} else {
return false;
}
}
}
} else if (typeof expected === 'function') {
for (var _cntr3 = 0; _cntr3 < dataArray.length; _cntr3++) {
try {
var result = expected(dataArray[_cntr3]);
if (typeof result === 'undefined' || !result) {
throw new Error(message);
}
} catch (err) {
if (error) {
var _dataEntryString3 = (0, _typeof3.default)(dataArray[_cntr3]) === 'object' ? (0, _stringify2.default)(dataArray[_cntr3]) : dataArray[_cntr3];
throw _validateError(Error, '\'' + dataName + '.' + accessor + '[' + _cntr3 + ']\': \'' + _dataEntryString3 + '\' failed validation: ' + err.message + '.');
} else {
return false;
}
}
}
}
return true;
}
// TODO: add docs after upgrading to latest WebStorm / better object destructuring support.
// /**
// * Validates data entry with a typeof check and potentially tests against the values in any given expected set.
// *
// * @param {object} data - The object data to validate.
// *
// * @param {string} accessor - A string describing the entries to access.
// *
// * @param {string} [type] - Tests with a typeof check.
// *
// * @param {function|Set<*>} [expected] - Optional function or set of expected values to test against.
// *
// * @param {string} [message] - Optional message to include.
// *
// * @param {boolean} [required=true] - When false if the accessor is missing validation is skipped.
// *
// * @param {boolean} [error=true] - When true and error is thrown otherwise a boolean is returned.
// *
// * @param {string} [dataName='data'] - Optional name of data.
// *
// * @returns {boolean} True if validation passes otherwise an exception is thrown.
// */
}, {
key: 'validateEntry',
value: function validateEntry(data, accessor) {
var _ref2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
_ref2$type = _ref2.type,
type = _ref2$type === undefined ? void 0 : _ref2$type,
_ref2$expected = _ref2.expected,
expected = _ref2$expected === undefined ? void 0 : _ref2$expected,
_ref2$message = _ref2.message,
message = _ref2$message === undefined ? void 0 : _ref2$message,
_ref2$required = _ref2.required,
required = _ref2$required === undefined ? true : _ref2$required,
_ref2$error = _ref2.error,
error = _ref2$error === undefined ? true : _ref2$error;
var dataName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'data';
var dataEntry = ObjectUtil.safeAccess(data, accessor);
// A non-required entry is missing so return without validation.
if (!required && typeof dataEntry === 'undefined') {
return true;
}
if (type && (typeof dataEntry === 'undefined' ? 'undefined' : (0, _typeof3.default)(dataEntry)) !== type) {
if (error) {
throw _validateError(TypeError, '\'' + dataName + '.' + accessor + '\' is not a \'' + type + '\'.');
} else {
return false;
}
}
if (expected instanceof _set2.default && !expected.has(dataEntry) || Array.isArray(expected) && expected.indexOf(dataEntry) < 0) {
if (error) {
var dataEntryString = (typeof dataEntry === 'undefined' ? 'undefined' : (0, _typeof3.default)(dataEntry)) === 'object' ? (0, _stringify2.default)(dataEntry) : dataEntry;
throw _validateError(Error, '\'' + dataName + '.' + accessor + '\': \'' + dataEntryString + '\' is not an expected value: ' + (0, _stringify2.default)(expected) + '.');
} else {
return false;
}
} else if (typeof expected === 'function') {
try {
var result = expected(dataEntry);
if (typeof result === 'undefined' || !result) {
throw new Error(message);
}
} catch (err) {
if (error) {
var _dataEntryString4 = (typeof dataEntry === 'undefined' ? 'undefined' : (0, _typeof3.default)(dataEntry)) === 'object' ? (0, _stringify2.default)(dataEntry) : dataEntry;
throw _validateError(Error, '\'' + dataName + '.' + accessor + '\': \'' + _dataEntryString4 + '\' failed to validate: ' + err.message + '.');
} else {
return false;
}
}
}
return true;
}
/**
* Dispatches validation of data entry to string or array validation depending on data entry type.
*
* @param {object} data - The data object to test.
*
* @param {string} accessor - A string describing the entries to access.
*
* @param {ValidationEntry} [entry] - A validation entry.
*
* @param {string} [dataName='data'] - Optional name of data.
*
* @returns {boolean} True if validation passes otherwise an exception is thrown.
*/
}, {
key: 'validateEntryOrArray',
value: function validateEntryOrArray(data, accessor, entry) {
var dataName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'data';
var dataEntry = ObjectUtil.safeAccess(data, accessor);
var result = void 0;
if (Array.isArray(dataEntry)) {
result = ObjectUtil.validateArray(data, accessor, entry, dataName);
} else {
result = ObjectUtil.validateEntry(data, accessor, entry, dataName);
}
return result;
}
}]);
return ObjectUtil;
}();
/**
* Wires up ObjectUtil on the plugin eventbus. The following event bindings are available:
*
* `typhonjs:object:util:depth:traverse`: Invokes `depthTraverse`.
* `typhonjs:object:util:get:accessor:list`: Invokes `getAccessorList`.
* `typhonjs:object:util:safe:access`: Invokes `safeAccess`.
* `typhonjs:object:util:safe:equal`: Invokes `safeEqual`.
* `typhonjs:object:util:safe:set`: Invokes `safeSet`.
* `typhonjs:object:util:safe:set:all`: Invokes `safeSetAll`.
* `typhonjs:object:util:validate`: Invokes `validate`.
* `typhonjs:object:util:validate:array`: Invokes `validateArray`.
* `typhonjs:object:util:validate:entry`: Invokes `validateEntry`.
*
* @param {PluginEvent} ev - The plugin event.
* @ignore
*/
exports.default = ObjectUtil;
function onPluginLoad(ev) {
var eventbus = ev.eventbus;
eventbus.on('typhonjs:object:util:depth:traverse', ObjectUtil.depthTraverse, ObjectUtil);
eventbus.on('typhonjs:object:util:get:accessor:list', ObjectUtil.getAccessorList, ObjectUtil);
eventbus.on('typhonjs:object:util:safe:access', ObjectUtil.safeAccess, ObjectUtil);
eventbus.on('typhonjs:object:util:safe:equal', ObjectUtil.safeEqual, ObjectUtil);
eventbus.on('typhonjs:object:util:safe:set', ObjectUtil.safeSet, ObjectUtil);
eventbus.on('typhonjs:object:util:safe:set:all', ObjectUtil.safeSetAll, ObjectUtil);
eventbus.on('typhonjs:object:util:validate', ObjectUtil.validate, ObjectUtil);
eventbus.on('typhonjs:object:util:validate:array', ObjectUtil.validateArray, ObjectUtil);
eventbus.on('typhonjs:object:util:validate:entry', ObjectUtil.validateEntry, ObjectUtil);
eventbus.on('typhonjs:object:util:validate:entry|array', ObjectUtil.validateEntryOrArray, ObjectUtil);
}
// Module private ---------------------------------------------------------------------------------------------------
/**
* Creates a new error of type `clazz` adding the field `_objectValidateError` set to true.
*
* @param {Error} clazz - Error class to instantiate.
*
* @param {string} message - An error message.
*
* @returns {*}
* @ignore
* @private
*/
function _validateError(clazz) {
var message = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : void 0;
var error = new clazz(message);
error._objectValidateError = true;
return error;
}
/**
* Private implementation of depth traversal.
*
* @param {object|Array} data - An object or array.
*
* @param {function} func - A callback function to process leaf values in children arrays or object members.
*
* @param {boolean} modify - If true then the result of the callback function is used to modify in place
* the given data.
* @returns {*}

@@ -238,18 +771,31 @@ * @ignore

*/
exports.default = ObjectUtil;
function _depthTraverse(data, func) {
if (Array.isArray(data)) {
for (var cntr = 0; cntr < data.length; cntr++) {
data[cntr] = _depthTraverse(data[cntr], func);
function _depthTraverse(data, func, modify) {
if (modify) {
if (Array.isArray(data)) {
for (var cntr = 0; cntr < data.length; cntr++) {
data[cntr] = _depthTraverse(data[cntr], func, modify);
}
} else if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) === 'object') {
for (var key in data) {
if (data.hasOwnProperty(key)) {
data[key] = _depthTraverse(data[key], func, modify);
}
}
} else {
data = func(data);
}
} else if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object') {
for (var key in data) {
if (data.hasOwnProperty(key)) {
data[key] = _depthTraverse(data[key], func);
} else {
if (Array.isArray(data)) {
for (var _cntr4 = 0; _cntr4 < data.length; _cntr4++) {
_depthTraverse(data[_cntr4], func, modify);
}
} else if ((typeof data === 'undefined' ? 'undefined' : (0, _typeof3.default)(data)) === 'object') {
for (var _key in data) {
if (data.hasOwnProperty(_key)) {
_depthTraverse(data[_key], func, modify);
}
}
} else {
func(data);
}
} else {
data = func(data);
}

@@ -274,3 +820,3 @@

if (data.hasOwnProperty(key)) {
if (_typeof(data[key]) === 'object') {
if ((0, _typeof3.default)(data[key]) === 'object') {
var childKeys = _getAccessorList(data[key]);

@@ -292,3 +838,2 @@

return accessors;
}
module.exports = exports['default'];
}

@@ -7,8 +7,24 @@ 'use strict';

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _isInteger = require('babel-runtime/core-js/number/is-integer');
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _isInteger2 = _interopRequireDefault(_isInteger);
var _templateObject = _taggedTemplateLiteral(['', '', '', '', ''], ['', '', '', '', '']);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
var _taggedTemplateLiteral2 = require('babel-runtime/helpers/taggedTemplateLiteral');
var _taggedTemplateLiteral3 = _interopRequireDefault(_taggedTemplateLiteral2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _templateObject = (0, _taggedTemplateLiteral3.default)(['', '', '', '', ''], ['', '', '', '', '']);
var _ObjectUtil = require('./ObjectUtil');

@@ -20,6 +36,2 @@

function _taggedTemplateLiteral(strings, raw) { return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -30,6 +42,6 @@ * Provides common string utilities.

function StringUtil() {
_classCallCheck(this, StringUtil);
(0, _classCallCheck3.default)(this, StringUtil);
}
_createClass(StringUtil, null, [{
(0, _createClass3.default)(StringUtil, null, [{
key: 'compare',

@@ -61,3 +73,3 @@

value: function incrementIndent(indentation) {
var amount = arguments.length <= 1 || arguments[1] === undefined ? 3 : arguments[1];
var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;

@@ -79,3 +91,3 @@ return indentation + amount;

value: function indent(indentation) {
var string = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
var string = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';

@@ -110,5 +122,5 @@ return new Array(indentation + 1).join(' ') + string;

value: function safeStringObject(string, object, accessor) {
var newLine = arguments.length <= 3 || arguments[3] === undefined ? 1 : arguments[3];
var appendString = arguments.length <= 4 || arguments[4] === undefined ? '' : arguments[4];
var tagFunction = arguments.length <= 5 || arguments[5] === undefined ? void 0 : arguments[5];
var newLine = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
var appendString = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : '';
var tagFunction = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : void 0;

@@ -175,3 +187,3 @@ var value = _ObjectUtil2.default.safeAccess(object, accessor);

value: function safeStringsPrependObject(origPrepend, object) {
if ((typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') {
if ((typeof object === 'undefined' ? 'undefined' : (0, _typeof3.default)(object)) !== 'object') {
return '';

@@ -239,3 +251,2 @@ }

}]);
return StringUtil;

@@ -264,8 +275,7 @@ }();

function SafeEntry(prependString, accessor) {
var newLine = arguments.length <= 2 || arguments[2] === undefined ? 1 : arguments[2];
var appendString = arguments.length <= 3 || arguments[3] === undefined ? '' : arguments[3];
var tagFunction = arguments.length <= 4 || arguments[4] === undefined ? void 0 : arguments[4];
var newLine = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
var appendString = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
var tagFunction = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : void 0;
(0, _classCallCheck3.default)(this, SafeEntry);
_classCallCheck(this, SafeEntry);
if (typeof prependString !== 'string') {

@@ -285,3 +295,3 @@ throw new TypeError('ctor error: \'prependString\' is not a \'string\'.');

if (Number.isInteger(newLine) && newLine < 0) {
if ((0, _isInteger2.default)(newLine) && newLine < 0) {
throw new TypeError('ctor error: \'newLine\' is not a positive \'integer\' (' + newLine + ').');

@@ -332,3 +342,3 @@ }

_createClass(SafeEntry, [{
(0, _createClass3.default)(SafeEntry, [{
key: 'accessor',

@@ -383,3 +393,2 @@ get: function get() {

}]);
return SafeEntry;

@@ -386,0 +395,0 @@ }();

{
"name": "typhonjs-escomplex-commons",
"version": "0.0.16",
"version": "0.1.0",
"homepage": "https://github.com/typhonjs-node-escomplex/typhonjs-escomplex-commons/",

@@ -8,3 +8,3 @@ "description": "Provides core common utilities for typhonjs-escomplex modules and plugins.",

"author": {
"name": "Mike Leahy"
"name": "Michael Leahy"
},

@@ -17,3 +17,3 @@ "repository": {

{
"name": "Mike Leahy",
"name": "Michael Leahy",
"email": "support@typhonjs.io",

@@ -24,5 +24,5 @@ "url": "https://github.com/typhonrt"

"devDependencies": {
"typhonjs-config-eslint": "^0.4.0",
"typhonjs-config-eslint": "^0.5.0",
"typhonjs-escomplex-test-data": "git+https://git@github.com/typhonjs-node-escomplex/typhonjs-escomplex-test-data.git",
"typhonjs-npm-build-test": "^0.3.0"
"typhonjs-npm-build-test": "^0.7.0"
},

@@ -35,3 +35,5 @@ "scripts": {

"test": "babel-node ./node_modules/typhonjs-npm-scripts-test-mocha/scripts/mocha.js",
"test-coverage": "babel-node ./node_modules/typhonjs-npm-scripts-test-mocha/scripts/mocha-istanbul.js"
"test-coverage": "babel-node ./node_modules/typhonjs-npm-scripts-test-mocha/scripts/mocha-istanbul.js",
"dev-test": "BABEL_ENV=escomplex-dev babel-node ./node_modules/typhonjs-npm-scripts-test-mocha/scripts/mocha.js dev_test",
"dev-test-coverage": "BABEL_ENV=escomplex-dev babel-node ./node_modules/typhonjs-npm-scripts-test-mocha/scripts/mocha-istanbul.js dev_test"
},

@@ -38,0 +40,0 @@ "keywords": [

import TransformFormat from '../../transform/TransformFormat';
/**
* Provides several helper methods to work with method oriented data stored as `this.methodAggregate` in `ClassReport` /
* Provides several helper methods to work with method oriented data stored as `this.aggregate` in `ClassReport` /
* `ModuleReport` and directly in `ClassMethodReport` / `ModuleMethodReport`.

@@ -11,22 +11,22 @@ */

* If given assigns the method report to an internal variable. This is used by `ClassReport` and `ModuleReport`
* which stores a `AggregateMethodReport` respectively in `this.methodAggregate`.
* which stores a `AggregateReport` respectively in `this.aggregate`.
*
* @param {AggregateMethodReport} aggregateMethodReport - An AggregateMethodReport to associate with this report.
* @param {AggregateReport} aggregateReport - An AggregateReport to associate with this report.
*/
constructor(aggregateMethodReport = void 0)
constructor(aggregateReport = void 0)
{
/**
* Stores any associated `AggregateMethodReport`.
* @type {AggregateMethodReport}
* Stores any associated `AggregateReport`.
* @type {AggregateReport}
*/
this.methodAggregate = aggregateMethodReport;
this.aggregate = aggregateReport;
}
/**
* Returns the associated `AggregateMethodReport` or `this`. Both ClassReport and ModuleReport have an
* `methodAggregate` AggregateMethodReport.
* Returns the associated `AggregateReport` or `this`. Both ClassReport and ModuleReport have an
* `aggregate` AggregateReport.
*
* @returns {AggregateMethodReport}
* @returns {AggregateReport}
*/
get aggregateMethodReport() { return typeof this.methodAggregate !== 'undefined' ? this.methodAggregate : this; }
get aggregateReport() { return typeof this.aggregate !== 'undefined' ? this.aggregate : this; }

@@ -33,0 +33,0 @@ /**

import HalsteadAverage from './HalsteadAverage';
import ObjectUtil from '../../../utils/ObjectUtil';
/**

@@ -35,3 +37,3 @@ * Provides all the averaged method metric data.

*/
this.params = 0;
this.paramCount = 0;

@@ -44,2 +46,19 @@ /**

}
/**
* Returns the object accessor list / keys for MethodAverage.
*
* @returns {Array<string>}
*/
get keys()
{
return s_AVERAGE_KEYS;
}
}
/**
* Defines the default method average accessor list / keys.
* @type {Array<string>}
* @ignore
*/
const s_AVERAGE_KEYS = ObjectUtil.getAccessorList(new MethodAverage());
import MethodAverage from './MethodAverage';
import ObjectUtil from '../../../utils/ObjectUtil';
/**

@@ -21,2 +23,19 @@ * Provides all the averaged module metric data.

}
/**
* Returns the object accessor list / keys for ModuleAverage.
*
* @returns {Array<string>}
*/
get keys()
{
return s_AVERAGE_KEYS;
}
}
/**
* Defines the default module average accessor list / keys.
* @type {Array<string>}
* @ignore
*/
const s_AVERAGE_KEYS = ObjectUtil.getAccessorList(new ModuleAverage());

@@ -12,2 +12,27 @@ import MethodReport from './MethodReport';

/**
* Initializes class module method report.
*
* @param {string} name - Name of the method.
* @param {number} paramNames - Array of any associated parameter names.
* @param {number} lineStart - Start line of method.
* @param {number} lineEnd - End line of method.
*/
constructor(name, paramNames, lineStart, lineEnd)
{
super(name, paramNames, lineStart, lineEnd);
/**
* Stores the max nested method depth.
* @type {number}
*/
this.maxNestedMethodDepth = 0;
/**
* Stores all nested method data.
* @type {Array<NestedMethodReport>}
*/
this.nestedMethods = [];
}
/**
* Returns the enum for the report type.

@@ -14,0 +39,0 @@ * @returns {CLASS_METHOD}

import AbstractReport from './AbstractReport';
import AggregateMethodReport from './AggregateMethodReport';
import AggregateReport from './AggregateReport';
import ClassMethodReport from './ClassMethodReport';

@@ -28,8 +28,9 @@ import MethodAverage from './averages/MethodAverage';

* @param {string} name - Name of the class.
* @param {string} superClassName - Name of any associated super class.
* @param {number} lineStart - Start line of class.
* @param {number} lineEnd - End line of class.
*/
constructor(name = '', lineStart = 0, lineEnd = 0)
constructor(name = void 0, superClassName = void 0, lineStart = 0, lineEnd = 0)
{
super(new AggregateMethodReport(lineStart, lineEnd));
super(new AggregateReport(lineStart, lineEnd, 0));

@@ -61,4 +62,10 @@ /**

/**
* Stores the average class aggregate & method metric data.
* @type {MethodAverage}
*/
this.aggregateAverage = new MethodAverage();
/**
* Stores the average method metric data.
* @type {HalsteadAverage}
* @type {MethodAverage}
*/

@@ -72,2 +79,8 @@ this.methodAverage = new MethodAverage();

this.name = name;
/**
* The name of any associated super class.
* @type {string}
*/
this.superClassName = superClassName;
}

@@ -74,0 +87,0 @@

@@ -5,4 +5,12 @@ import ClassReport from '../ClassReport';

/**
* ModuleScopeControl
*/
export default class ModuleScopeControl
{
/**
* Creates ModuleScopeControl instance with given ModuleReport.
*
* @param {ModuleReport} moduleReport - An associated module report.
*/
constructor(moduleReport)

@@ -12,2 +20,6 @@ {

this._anonClassCntr = 1;
this._anonMethodCntr = 1;
/**

@@ -24,2 +36,8 @@ * Stores the current class report scope stack which is lazily created in `createScope`.

this._scopeStackMethod = [];
/**
* Stores the current nested method report scope stack which is lazily created in `createScope`.
* @type {Array<ClassMethodReport|ModuleMethodReport>}
*/
this._scopeStackNestedMethod = [];
}

@@ -36,3 +54,3 @@

* (number) lineEnd - End line of method.
* (number) paramCount - (For method scopes) Number of parameters for method.
* (Array<string>) paramNames - (For method scopes) An array of parameters names for method.
* ```

@@ -71,14 +89,26 @@ *

case 'class':
report = new ClassReport(newScope.name, newScope.lineStart, newScope.lineEnd);
{
// Create a specific anonymous class name if applicable.
const className = newScope.name !== '<anonymous>' ? newScope.name : `<anon class-${this._anonClassCntr++}>`;
const superClassName = newScope.superClassName !== '<anonymous>' ? newScope.superClassName :
`<anon class-${this._anonClassCntr++}>`;
report = new ClassReport(className, superClassName, newScope.lineStart, newScope.lineEnd);
this._report.classes.push(report);
this._scopeStackClass.push(report);
break;
}
case 'method':
{
if (!Number.isInteger(newScope.paramCount))
if (!Array.isArray(newScope.paramNames))
{
throw new TypeError(`createScope error: 'newScope.paramCount' is not an 'integer'.`);
throw new TypeError(`createScope error: 'newScope.paramNames' is not an 'array'.`);
}
// Create a specific anonymous method name if applicable.
const methodName = newScope.name !== '<anonymous>' ? newScope.name :
`<anon method-${this._anonMethodCntr++}>`;
// If an existing class report / scope exists also push the method to the class report.

@@ -89,3 +119,3 @@ const classReport = this.getCurrentClassReport();

{
report = new ClassMethodReport(newScope.name, newScope.lineStart, newScope.lineEnd, newScope.paramCount);
report = new ClassMethodReport(methodName, newScope.paramNames, newScope.lineStart, newScope.lineEnd);
classReport.methods.push(report);

@@ -95,4 +125,3 @@ }

{
report = new ModuleMethodReport(newScope.name, newScope.lineStart, newScope.lineEnd,
newScope.paramCount);
report = new ModuleMethodReport(methodName, newScope.paramNames, newScope.lineStart, newScope.lineEnd);

@@ -99,0 +128,0 @@ // Add this report to the module methods as there is no current class report.

@@ -1,9 +0,12 @@

import AggregateMethodReport from './AggregateMethodReport';
import AggregateReport from './AggregateReport';
import AnalyzeError from '../../analyze/AnalyzeError';
// import NestedMethodReport from './NestedMethodReport';
import ObjectUtil from '../../utils/ObjectUtil';
/**
* Provides the method report object which stores data pertaining to a single method / function.
*/
export default class MethodReport extends AggregateMethodReport
export default class MethodReport extends AggregateReport
{

@@ -14,7 +17,7 @@ /**

* @param {string} name - Name of the method.
* @param {number} paramNames - Array of any associated parameter names.
* @param {number} lineStart - Start line of method.
* @param {number} lineEnd - End line of method.
* @param {number} params - Number of parameters for method.
*/
constructor(name = '', lineStart = 0, lineEnd = 0, params = 0)
constructor(name = void 0, paramNames = [], lineStart = 0, lineEnd = 0)
{

@@ -48,6 +51,12 @@ super(lineStart, lineEnd);

/**
* The number of parameters for the method or report.
* Stores any parameter names.
* @type {Array<string>}
*/
this.paramNames = paramNames;
/**
* The number of parameters for the method.
* @type {number}
*/
this.params = params;
this.paramCount = paramNames.length;
}

@@ -57,10 +66,43 @@

* Clears all errors stored in the method report.
*
* @param {boolean} clearChildren - (Optional) If false then nested method errors are not cleared; default (true).
*/
clearErrors()
clearErrors(clearChildren = true)
{
this.errors = [];
if (clearChildren && Array.isArray(this.nestedMethods))
{
this.nestedMethods.forEach((report) => { report.clearErrors(); });
}
}
// TODO: Remove? Old implementation
// /**
// * Gets all errors stored in the method report.
// *
// * @param {object} options - Optional parameters.
// * @property {boolean} includeChildren - If false then module errors are not included; default (true).
// * @property {boolean} includeReports - If true then results will be an array of object hashes containing `source`
// * (the source report object of the error) and `error`
// * (an AnalyzeError instance) keys; default (false).
// *
// * @returns {Array<AnalyzeError|{error: AnalyzeError, source: *}>}
// */
// getErrors(options = { includeChildren: true, includeReports: false })
// {
// /* istanbul ignore if */
// if (typeof options !== 'object') { throw new TypeError(`getErrors error: 'options' is not an 'object'.`); }
//
// // By default set includeChildren to true.
// /* istanbul ignore if */
// if (typeof options.includeChildren !== 'boolean') { options.includeChildren = true; }
//
// // If `includeReports` is true then return an object hash with the source and error otherwise return the error.
// return options.includeReports ? this.errors.map((entry) => { return { error: entry, source: this }; }) :
// [].concat(...this.errors);
// }
/**
* Gets all errors stored in the method report.
* Gets all errors stored in the method report and by default any nested methods.
*

@@ -85,4 +127,34 @@ * @param {object} options - Optional parameters.

// If `includeReports` is true then return an object hash with the source and error otherwise return the error.
return options.includeReports ? this.errors.map((entry) => { return { error: entry, source: this }; }) :
let errors = options.includeReports ? this.errors.map((entry) => { return { error: entry, source: this }; }) :
[].concat(...this.errors);
// If `includeChildren` is true then traverse all children reports for errors.
if (options.includeChildren && Array.isArray(this.nestedMethods))
{
// Add class to all children errors.
if (options.includeReports)
{
const childErrors = [];
this.nestedMethods.forEach((report) => { childErrors.push(...report.getErrors(options)); });
// Add module to object hash.
childErrors.forEach((error) => { error.method = this; });
// Push to all module errors.
errors.push(...childErrors);
}
else
{
this.nestedMethods.forEach((report) => { errors.push(...report.getErrors(options)); });
}
}
// If `options.query` is defined then filter errors against the query object.
if (typeof options.query === 'object')
{
errors = errors.filter((error) => ObjectUtil.safeEqual(options.query, error));
}
return errors;
}

@@ -121,4 +193,10 @@

// TODO unimplemented yet!
// if (methodReport.nestedMethods.length > 0)
// {
// methodReport.nestedMethods = methodReport.nestedMethods.map((method) => NestedMethodReport.parse(method));
// }
return methodReport;
}
}

@@ -12,2 +12,27 @@ import MethodReport from './MethodReport';

/**
* Initializes module method report.
*
* @param {string} name - Name of the method.
* @param {number} paramNames - Array of any associated parameter names.
* @param {number} lineStart - Start line of method.
* @param {number} lineEnd - End line of method.
*/
constructor(name, paramNames, lineStart, lineEnd)
{
super(name, paramNames, lineStart, lineEnd);
/**
* Stores the max nested method depth.
* @type {number}
*/
this.maxNestedMethodDepth = 0;
/**
* Stores all nested method data.
* @type {Array<NestedMethodReport>}
*/
this.nestedMethods = [];
}
/**
* Returns the enum for the report type.

@@ -14,0 +39,0 @@ * @returns {ReportType}

import AbstractReport from './AbstractReport';
import AggregateMethodReport from './AggregateMethodReport';
import AggregateReport from './AggregateReport';
import ClassReport from './ClassReport';

@@ -40,3 +40,3 @@ import MethodAverage from './averages/MethodAverage';

{
super(new AggregateMethodReport(lineStart, lineEnd));
super(new AggregateReport(lineStart, lineEnd));

@@ -86,3 +86,3 @@ /**

/**
* Measures the average method maintainability index for the module / file.
* Measures the average maintainability index for the module / file.
* @type {number}

@@ -99,5 +99,11 @@ */

/**
* Stores the average method metric data.
* Stores the average module / class aggregate & method metric data.
* @type {MethodAverage}
*/
this.aggregateAverage = new MethodAverage();
/**
* Stores just the average method metric data.
* @type {MethodAverage}
*/
this.methodAverage = new MethodAverage();

@@ -104,0 +110,0 @@

@@ -21,2 +21,6 @@ import HalsteadArray from './HalsteadArray';

{
// Do not wrap ignoreKeys in an array if it is `null` or a `function`. For functions this allows Trait evaluation
// via `Trait->valueOf` to return `null` and not `null` wrapped in an `array`.
const ignoreKeysPassthru = ignoreKeys === null || typeof ignoreKeys === 'function';
return {

@@ -27,3 +31,3 @@ lloc: new Trait('lloc', lloc),

operands: new HalsteadArray('operands', TraitUtil.safeArray(operands)),
ignoreKeys: new Trait('ignoreKeys', TraitUtil.safeArray(ignoreKeys)),
ignoreKeys: new Trait('ignoreKeys', ignoreKeysPassthru ? ignoreKeys : TraitUtil.safeArray(ignoreKeys)),
newScope: new Trait('newScope', newScope),

@@ -30,0 +34,0 @@ dependencies: new Trait('dependencies', dependencies)

@@ -0,1 +1,4 @@

/**
* TraitUtil
*/
export default class TraitUtil

@@ -2,0 +5,0 @@ {

@@ -20,2 +20,7 @@ import ObjectUtil from '../../../utils/ObjectUtil';

{
/**
* Initializes
*
* @param {object} thresholds - Defines thresholds.
*/
constructor(thresholds = s_DEFAULT_THRESHOLDS)

@@ -173,2 +178,10 @@ {

/**
* Parses errors from report
*
* @param {object} sourceObject - A report object
* @param {object} options - Options
* @param {Array} errors - An array to accumulate errors.
* @private
*/
_parseErrors(sourceObject, options, errors)

@@ -175,0 +188,0 @@ {

@@ -10,2 +10,8 @@ import ObjectUtil from '../../../utils/ObjectUtil';

{
/**
* Initializes format.
*
* @param {object} keys - Defines the keys to include in a minimal JSON representation of class / class method /
* module method / module / project reports.
*/
constructor(keys = s_DEFAULT_KEYS)

@@ -40,2 +46,3 @@ {

case ReportType.MODULE_METHOD:
case ReportType.NESTED_METHOD:
output = this._formatMethod(report, localOptions);

@@ -106,2 +113,3 @@ break;

case ReportType.MODULE:
case ReportType.NESTED_METHOD:
case ReportType.PROJECT:

@@ -108,0 +116,0 @@ return true;

@@ -9,2 +9,10 @@ import FormatText from '../text/FormatText';

{
/**
* Initializes markdown format.
*
* @param {object} headers -
* @param {object} keys -
* @param {string} adjacencyFormatName -
* @param {string} visibilityFormatName -
*/
constructor(headers = {}, keys = {}, adjacencyFormatName = 'markdown-adjacency',

@@ -11,0 +19,0 @@ visibilityFormatName = 'markdown-visibility')

@@ -8,2 +8,8 @@ import FormatTextAdjacency from '../text/FormatTextAdjacency';

{
/**
* Initializes markdown adjacency format.
*
* @param {object} headers -
* @param {object} keys -
*/
constructor(headers = {}, keys = {})

@@ -10,0 +16,0 @@ {

@@ -11,2 +11,8 @@ import FormatTextMinimal from '../text/FormatTextMinimal';

{
/**
* Initializes minimal markdown format.
*
* @param {object} headers -
* @param {object} keys -
*/
constructor(headers = {}, keys = {})

@@ -13,0 +19,0 @@ {

@@ -10,2 +10,8 @@ import FormatTextModules from '../text/FormatTextModules';

{
/**
* Initializes minimal markdown modules format.
*
* @param {object} headers -
* @param {object} keys -
*/
constructor(headers = {}, keys = {})

@@ -12,0 +18,0 @@ {

@@ -8,2 +8,8 @@ import FormatTextVisibility from '../text/FormatTextVisibility';

{
/**
* Initializes visibility markdown format.
*
* @param {object} headers -
* @param {object} keys -
*/
constructor(headers = {}, keys = {})

@@ -10,0 +16,0 @@ {

@@ -57,2 +57,6 @@ import ObjectUtil from '../../../utils/ObjectUtil';

case ReportType.NESTED_METHOD:
output = this._formatMethod(report, localOptions, '', false).replace(/^[\n]/, '');
break;
case ReportType.PROJECT:

@@ -388,2 +392,2 @@ output = this._formatProject(report, localOptions);

}
}
}

@@ -12,2 +12,10 @@ import AbstractFormatText from './AbstractFormatText';

{
/**
* Initializes text format.
*
* @param {object} headers -
* @param {object} keys -
* @param {string} adjacencyFormatName -
* @param {string} visibilityFormatName -
*/
constructor(headers = {}, keys = {}, adjacencyFormatName = 'text-adjacency',

@@ -67,2 +75,3 @@ visibilityFormatName = 'text-visibility')

case ReportType.MODULE:
case ReportType.NESTED_METHOD:
case ReportType.PROJECT:

@@ -242,2 +251,2 @@ return true;

]
};
};

@@ -8,2 +8,8 @@ import AbstractTextMatrix from './AbstractTextMatrix';

{
/**
* Initializes text adjacency format.
*
* @param {object} headers -
* @param {object} keys -
*/
constructor(headers = {}, keys = {})

@@ -10,0 +16,0 @@ {

@@ -12,2 +12,8 @@ import AbstractFormatTest from './AbstractFormatText';

{
/**
* Initializes minimal text format.
*
* @param {object} headers -
* @param {object} keys -
*/
constructor(headers = {}, keys = {})

@@ -63,2 +69,3 @@ {

case ReportType.MODULE:
case ReportType.NESTED_METHOD:
case ReportType.PROJECT:

@@ -65,0 +72,0 @@ return true;

@@ -12,2 +12,8 @@ import AbstractFormatTest from './AbstractFormatText';

{
/**
* Initializes text modules format.
*
* @param {object} headers -
* @param {object} keys -
*/
constructor(headers = {}, keys = {})

@@ -14,0 +20,0 @@ {

@@ -8,2 +8,8 @@ import AbstractTextMatrix from './AbstractTextMatrix';

{
/**
* Initializes text visibility format.
*
* @param {object} headers -
* @param {object} keys -
*/
constructor(headers = {}, keys = {})

@@ -10,0 +16,0 @@ {

@@ -25,2 +25,5 @@ import FormatJSON from './formats/json/FormatJSON';

/**
* TransformFormat
*/
export default class TransformFormat

@@ -131,2 +134,3 @@ {

case ReportType.MODULE:
case ReportType.NESTED_METHOD:
case ReportType.PROJECT:

@@ -133,0 +137,0 @@ return formatter.formatReport(report, options);

import Enum from '../utils/Enum';
/**
* Defines ReportType enum.
*/
export default class ReportType extends Enum {}

@@ -11,3 +14,4 @@

MODULE: { description: 'Module' },
NESTED_METHOD: { description: 'Nested Method' },
PROJECT: { description: 'Project' }
});

@@ -6,2 +6,5 @@ /**

{
/**
* Initializes ASTData
*/
constructor()

@@ -14,2 +17,7 @@ {

/**
* Appends a string.
*
* @param {string} string - A string to append.
*/
write(string)

@@ -20,2 +28,7 @@ {

/**
* Convert to string
*
* @returns {string|*|string}
*/
toString()

@@ -22,0 +35,0 @@ {

@@ -5,2 +5,5 @@ import ASTData from './ASTData';

/**
* ASTState
*/
export default class ASTState

@@ -7,0 +10,0 @@ {

@@ -779,6 +779,11 @@ /* eslint-disable eqeqeq */

output.write(', ');
output.operators.push(',');
}
else
{
if (element == null) { output.write(', '); }
if (element == null)
{
output.write(', ');
output.operators.push(',');
}
break;

@@ -840,3 +845,3 @@ }

{
if (node.method || node.kind[0] !== 'i')
if (node.method || (node.kind && node.kind[0] !== 'i'))
{

@@ -1169,3 +1174,3 @@ this.MethodDefinition(node, state); // Either a method or of kind `set` or `get` (not `init`)

state.output.write(node.value);
state.output.operands.push(node.value);
state.output.operands.push(JSON.stringify(node.value));
},

@@ -1176,3 +1181,3 @@

state.output.write(node.value);
state.output.operands.push(node.value);
state.output.operands.push(JSON.stringify(node.value));
},

@@ -1189,3 +1194,3 @@

state.output.write(node.value);
state.output.operands.push(node.value);
state.output.operands.push(JSON.stringify(node.value));
},

@@ -1206,2 +1211,2 @@

}
};
};
import expressionPrecedence from './expressionPrecedence';
import operatorPrecedence from './operatorPrecedence';
/**
* ASTUTil
*/
export default class ASTUtil

@@ -5,0 +8,0 @@ {

@@ -66,2 +66,8 @@ /**

/**
* Extracts enum values from an array.
*
* @param {Array} arr -
* @private
*/
static _enumValuesFromArray(arr)

@@ -72,2 +78,8 @@ {

/**
* Extracts enum values from an object.
*
* @param {object} obj -
* @private
*/
static _enumValuesFromObject(obj)

@@ -82,2 +94,9 @@ {

/**
* Pushes enum value.
*
* @param {object} enumValue -
* @param {string} name -
* @private
*/
static _pushEnumValue(enumValue, name)

@@ -84,0 +103,0 @@ {

@@ -100,3 +100,3 @@ import ObjectUtil from './ObjectUtil';

{
return ObjectUtil.depthTraverse(data, MathUtil.toFixed);
return ObjectUtil.depthTraverse(data, MathUtil.toFixed, true);
}

@@ -116,2 +116,2 @@

}
}
}
/**
* Provides common object manipulation utilities.
* Provides common object manipulation utilities including depth traversal, obtaining accessors, safely setting values /
* equality tests, and validation.
*
* Support for typhonjs-plugin-manager is enabled.
*/

@@ -11,7 +14,11 @@ export default class ObjectUtil

* @param {object|Array} data - An object or array.
*
* @param {function} func - A callback function to process leaf values in children arrays or object members.
*
* @param {boolean} modify - If true then the result of the callback function is used to modify in place
* the given data.
*
* @returns {*}
*/
static depthTraverse(data, func)
static depthTraverse(data, func, modify = false)
{

@@ -24,3 +31,3 @@ /* istanbul ignore if */

return _depthTraverse(data, func);
return _depthTraverse(data, func, modify);
}

@@ -48,3 +55,5 @@

* @param {object} data - An object to access entry data.
*
* @param {string} accessor - A string describing the entries to access.
*
* @param {*} defaultValue - (Optional) A default value to return if an entry for accessor is not found.

@@ -74,2 +83,46 @@ *

/**
* Provides a way to safely batch set an objects data / entries given an array of accessor strings which describe the
* entries to walk. To access deeper entries into the object format the accessor string with `.` between entries
* to walk. If value is an object the accessor will be used to access a target value from `value` which is
* subsequently set to `data` by the given operation. If `value` is not an object it will be used as the target
* value to set across all accessors.
*
* @param {object} data - An object to access entry data.
*
* @param {Array<string>} accessors - A string describing the entries to access.
*
* @param {object|*} value - A new value to set if an entry for accessor is found.
*
* @param {string} [operation='set'] - Operation to perform including: 'add', 'div', 'mult', 'set',
* 'set-undefined', 'sub'.
*
* @param {object|*} [defaultAccessValue=0] - A new value to set if an entry for accessor is found.
*
*
* @param {boolean} [createMissing=true] - If true missing accessor entries will be created as objects
* automatically.
*/
static safeBatchSet(data, accessors, value, operation = 'set', defaultAccessValue = 0, createMissing = true)
{
if (typeof data !== 'object') { throw new TypeError(`safeBatchSet Error: 'data' is not an 'object'.`); }
if (!Array.isArray(accessors)) { throw new TypeError(`safeBatchSet Error: 'accessors' is not an 'array'.`); }
if (typeof value === 'object')
{
accessors.forEach((accessor) =>
{
const targetValue = ObjectUtil.safeAccess(value, accessor, defaultAccessValue);
ObjectUtil.safeSet(data, accessor, targetValue, operation, createMissing);
});
}
else
{
accessors.forEach((accessor) =>
{
ObjectUtil.safeSet(data, accessor, value, operation, createMissing);
});
}
}
/**
* Compares a source object and values of entries against a target object. If the entries in the source object match

@@ -80,2 +133,3 @@ * the target object then `true` is returned otherwise `false`. If either object is undefined or null then false

* @param {object} source - Source object.
*
* @param {object} target - Target object.

@@ -113,10 +167,16 @@ *

* @param {object} data - An object to access entry data.
*
* @param {string} accessor - A string describing the entries to access.
*
* @param {*} value - A new value to set if an entry for accessor is found.
* @param {string} operation - (Optional) Operation to perform including: 'add', 'div', 'mult', 'set', 'sub';
* default (`set`).
*
* @param {string} [operation='set'] - Operation to perform including: 'add', 'div', 'mult', 'set',
* 'set-undefined', 'sub'.
*
* @param {boolean} [createMissing=true] - If true missing accessor entries will be created as objects
* automatically.
*
* @returns {boolean} True if successful.
*/
static safeSet(data, accessor, value, operation = 'set')
static safeSet(data, accessor, value, operation = 'set', createMissing = true)
{

@@ -131,5 +191,10 @@ if (typeof data !== 'object') { throw new TypeError(`safeSet Error: 'data' is not an 'object'.`); }

{
// If the next level of object access is undefined then create a new object entry.
if (typeof data[access[cntr]] === 'undefined') { data[access[cntr]] = {}; }
// If data is an array perform validation that the accessor is a positive integer otherwise quit.
if (Array.isArray(data))
{
const number = (+access[cntr]);
if (!Number.isInteger(number) || number < 0) { return false; }
}
if (cntr === access.length - 1)

@@ -155,2 +220,6 @@ {

case 'set-undefined':
if (typeof data[access[cntr]] === 'undefined') { data[access[cntr]] = value; }
break;
case 'sub':

@@ -163,2 +232,5 @@ data[access[cntr]] -= value;

{
// If createMissing is true and the next level of object access is undefined then create a new object entry.
if (createMissing && typeof data[access[cntr]] === 'undefined') { data[access[cntr]] = {}; }
// Abort if the next level is null or not an object and containing a value.

@@ -173,12 +245,389 @@ if (data[access[cntr]] === null || typeof data[access[cntr]] !== 'object') { return false; }

}
/**
* Performs bulk setting of values to the given data object.
*
* @param {object} data - The data object to set data.
*
* @param {object<string, *>} accessorValues - Object of accessor keys to values to set.
*
* @param {string} [operation='set'] - Operation to perform including: 'add', 'div', 'mult', 'set', 'sub';
* default (`set`).
*
* @param {boolean} [createMissing=true] - If true missing accessor entries will be created as objects
* automatically.
*/
static safeSetAll(data, accessorValues, operation = 'set', createMissing = true)
{
if (typeof data !== 'object') { throw new TypeError(`'data' is not an 'object'.`); }
if (typeof accessorValues !== 'object') { throw new TypeError(`'accessorValues' is not an 'object'.`); }
for (const accessor of Object.keys(accessorValues))
{
if (!accessorValues.hasOwnProperty(accessor)) { continue; }
ObjectUtil.safeSet(data, accessor, accessorValues[accessor], operation, createMissing);
}
}
/**
* Performs bulk validation of data given an object, `validationData`, which describes all entries to test.
*
* @param {object} data - The data object to test.
*
* @param {object<string, ValidationEntry>} validationData - Key is the accessor / value is a validation entry.
*
* @param {string} [dataName='data'] - Optional name of data.
*
* @returns {boolean} True if validation passes otherwise an exception is thrown.
*/
static validate(data, validationData = {}, dataName = 'data')
{
if (typeof data !== 'object') { throw new TypeError(`'${dataName}' is not an 'object'.`); }
if (typeof validationData !== 'object') { throw new TypeError(`'validationData' is not an 'object'.`); }
let result;
for (const key of Object.keys(validationData))
{
if (!validationData.hasOwnProperty(key)) { continue; }
const entry = validationData[key];
switch (entry.test)
{
case 'array':
result = ObjectUtil.validateArray(data, key, entry, dataName);
break;
case 'entry':
result = ObjectUtil.validateEntry(data, key, entry, dataName);
break;
case 'entry|array':
result = ObjectUtil.validateEntryOrArray(data, key, entry, dataName);
break;
}
}
return result;
}
// TODO: add docs after upgrading to latest WebStorm / better object destructuring support.
// /**
// * Validates all array entries against potential type and expected tests.
// *
// * @param {object} data - The data object to test.
// *
// * @param {string} accessor - A string describing the entries to access.
// *
// * @param {string} [type] - Tests with a typeof check.
// *
// * @param {function|Set<*>} [expected] - Optional function or set of expected values to test against.
// *
// * @param {string} [message] - Optional message to include.
// *
// * @param {boolean} [required] - When false if the accessor is missing validation is skipped.
// *
// * @param {boolean} [error=true] - When true and error is thrown otherwise a boolean is returned.
// *
// * @param {string} [dataName='data'] - Optional name of data.
// *
// * @returns {boolean} True if validation passes otherwise an exception is thrown.
// */
static validateArray(data, accessor, { type = void 0, expected = void 0, message = void 0, required = true,
error = true } = {}, dataName = 'data')
{
const dataArray = ObjectUtil.safeAccess(data, accessor);
// A non-required entry is missing so return without validation.
if (!required && typeof dataArray === 'undefined') { return true; }
if (!Array.isArray(dataArray))
{
if (error)
{
throw _validateError(TypeError, `'${dataName}.${accessor}' is not an 'array'.`);
}
else
{
return false;
}
}
if (typeof type === 'string')
{
for (let cntr = 0; cntr < dataArray.length; cntr++)
{
if (!(typeof dataArray[cntr] === type))
{
if (error)
{
const dataEntryString = typeof dataArray[cntr] === 'object' ? JSON.stringify(dataArray[cntr]) :
dataArray[cntr];
throw _validateError(TypeError,
`'${dataName}.${accessor}[${cntr}]': '${dataEntryString}' is not a '${type}'.`);
}
else
{
return false;
}
}
}
}
// If expected is a function then test all array entries against the test function. If expected is a Set then
// test all array entries for inclusion in the set. Otherwise if expected is a string then test that all array
// entries as a `typeof` test against expected.
if (Array.isArray(expected))
{
for (let cntr = 0; cntr < dataArray.length; cntr++)
{
if (expected.indexOf(dataArray[cntr]) < 0)
{
if (error)
{
const dataEntryString = typeof dataArray[cntr] === 'object' ? JSON.stringify(dataArray[cntr]) :
dataArray[cntr];
throw _validateError(Error, `'${dataName}.${accessor}[${cntr}]': '${
dataEntryString}' is not an expected value: ${JSON.stringify(expected)}.`);
}
else
{
return false;
}
}
}
}
else if (expected instanceof Set)
{
for (let cntr = 0; cntr < dataArray.length; cntr++)
{
if (!expected.has(dataArray[cntr]))
{
if (error)
{
const dataEntryString = typeof dataArray[cntr] === 'object' ? JSON.stringify(dataArray[cntr]) :
dataArray[cntr];
throw _validateError(Error, `'${dataName}.${accessor}[${cntr}]': '${
dataEntryString}' is not an expected value: ${JSON.stringify(expected)}.`);
}
else
{
return false;
}
}
}
}
else if (typeof expected === 'function')
{
for (let cntr = 0; cntr < dataArray.length; cntr++)
{
try
{
const result = expected(dataArray[cntr]);
if (typeof result === 'undefined' || !result) { throw new Error(message); }
}
catch (err)
{
if (error)
{
const dataEntryString = typeof dataArray[cntr] === 'object' ? JSON.stringify(dataArray[cntr]) :
dataArray[cntr];
throw _validateError(Error, `'${dataName}.${accessor}[${cntr}]': '${
dataEntryString}' failed validation: ${err.message}.`);
}
else
{
return false;
}
}
}
}
return true;
}
// TODO: add docs after upgrading to latest WebStorm / better object destructuring support.
// /**
// * Validates data entry with a typeof check and potentially tests against the values in any given expected set.
// *
// * @param {object} data - The object data to validate.
// *
// * @param {string} accessor - A string describing the entries to access.
// *
// * @param {string} [type] - Tests with a typeof check.
// *
// * @param {function|Set<*>} [expected] - Optional function or set of expected values to test against.
// *
// * @param {string} [message] - Optional message to include.
// *
// * @param {boolean} [required=true] - When false if the accessor is missing validation is skipped.
// *
// * @param {boolean} [error=true] - When true and error is thrown otherwise a boolean is returned.
// *
// * @param {string} [dataName='data'] - Optional name of data.
// *
// * @returns {boolean} True if validation passes otherwise an exception is thrown.
// */
static validateEntry(data, accessor, { type = void 0, expected = void 0, message = void 0, required = true,
error = true } = {}, dataName = 'data')
{
const dataEntry = ObjectUtil.safeAccess(data, accessor);
// A non-required entry is missing so return without validation.
if (!required && typeof dataEntry === 'undefined') { return true; }
if (type && typeof dataEntry !== type)
{
if (error)
{
throw _validateError(TypeError, `'${dataName}.${accessor}' is not a '${type}'.`);
}
else
{
return false;
}
}
if ((expected instanceof Set && !expected.has(dataEntry)) ||
(Array.isArray(expected) && expected.indexOf(dataEntry) < 0))
{
if (error)
{
const dataEntryString = typeof dataEntry === 'object' ? JSON.stringify(dataEntry) : dataEntry;
throw _validateError(Error, `'${dataName}.${accessor}': '${dataEntryString}' is not an expected value: ${
JSON.stringify(expected)}.`);
}
else
{
return false;
}
}
else if (typeof expected === 'function')
{
try
{
const result = expected(dataEntry);
if (typeof result === 'undefined' || !result) { throw new Error(message); }
}
catch (err)
{
if (error)
{
const dataEntryString = typeof dataEntry === 'object' ? JSON.stringify(dataEntry) : dataEntry;
throw _validateError(Error, `'${dataName}.${accessor}': '${dataEntryString}' failed to validate: ${
err.message}.`);
}
else
{
return false;
}
}
}
return true;
}
/**
* Dispatches validation of data entry to string or array validation depending on data entry type.
*
* @param {object} data - The data object to test.
*
* @param {string} accessor - A string describing the entries to access.
*
* @param {ValidationEntry} [entry] - A validation entry.
*
* @param {string} [dataName='data'] - Optional name of data.
*
* @returns {boolean} True if validation passes otherwise an exception is thrown.
*/
static validateEntryOrArray(data, accessor, entry, dataName = 'data')
{
const dataEntry = ObjectUtil.safeAccess(data, accessor);
let result;
if (Array.isArray(dataEntry))
{
result = ObjectUtil.validateArray(data, accessor, entry, dataName);
}
else
{
result = ObjectUtil.validateEntry(data, accessor, entry, dataName);
}
return result;
}
}
/**
* Wires up ObjectUtil on the plugin eventbus. The following event bindings are available:
*
* `typhonjs:object:util:depth:traverse`: Invokes `depthTraverse`.
* `typhonjs:object:util:get:accessor:list`: Invokes `getAccessorList`.
* `typhonjs:object:util:safe:access`: Invokes `safeAccess`.
* `typhonjs:object:util:safe:equal`: Invokes `safeEqual`.
* `typhonjs:object:util:safe:set`: Invokes `safeSet`.
* `typhonjs:object:util:safe:set:all`: Invokes `safeSetAll`.
* `typhonjs:object:util:validate`: Invokes `validate`.
* `typhonjs:object:util:validate:array`: Invokes `validateArray`.
* `typhonjs:object:util:validate:entry`: Invokes `validateEntry`.
*
* @param {PluginEvent} ev - The plugin event.
* @ignore
*/
export function onPluginLoad(ev)
{
const eventbus = ev.eventbus;
eventbus.on('typhonjs:object:util:depth:traverse', ObjectUtil.depthTraverse, ObjectUtil);
eventbus.on('typhonjs:object:util:get:accessor:list', ObjectUtil.getAccessorList, ObjectUtil);
eventbus.on('typhonjs:object:util:safe:access', ObjectUtil.safeAccess, ObjectUtil);
eventbus.on('typhonjs:object:util:safe:equal', ObjectUtil.safeEqual, ObjectUtil);
eventbus.on('typhonjs:object:util:safe:set', ObjectUtil.safeSet, ObjectUtil);
eventbus.on('typhonjs:object:util:safe:set:all', ObjectUtil.safeSetAll, ObjectUtil);
eventbus.on('typhonjs:object:util:validate', ObjectUtil.validate, ObjectUtil);
eventbus.on('typhonjs:object:util:validate:array', ObjectUtil.validateArray, ObjectUtil);
eventbus.on('typhonjs:object:util:validate:entry', ObjectUtil.validateEntry, ObjectUtil);
eventbus.on('typhonjs:object:util:validate:entry|array', ObjectUtil.validateEntryOrArray, ObjectUtil);
}
// Module private ---------------------------------------------------------------------------------------------------
/**
* Creates a new error of type `clazz` adding the field `_objectValidateError` set to true.
*
* @param {Error} clazz - Error class to instantiate.
*
* @param {string} message - An error message.
*
* @returns {*}
* @ignore
* @private
*/
function _validateError(clazz, message = void 0)
{
const error = new clazz(message);
error._objectValidateError = true;
return error;
}
/**
* Private implementation of depth traversal.
*
* @param {object|Array} data - An object or array.
*
* @param {function} func - A callback function to process leaf values in children arrays or object members.
*
* @param {boolean} modify - If true then the result of the callback function is used to modify in place
* the given data.
* @returns {*}

@@ -188,15 +637,39 @@ * @ignore

*/
function _depthTraverse(data, func)
function _depthTraverse(data, func, modify)
{
if (Array.isArray(data))
if (modify)
{
for (let cntr = 0; cntr < data.length; cntr++) { data[cntr] = _depthTraverse(data[cntr], func); }
if (Array.isArray(data))
{
for (let cntr = 0; cntr < data.length; cntr++)
{
data[cntr] = _depthTraverse(data[cntr], func, modify);
}
}
else if (typeof data === 'object')
{
for (const key in data)
{
if (data.hasOwnProperty(key)) { data[key] = _depthTraverse(data[key], func, modify); }
}
}
else
{
data = func(data);
}
}
else if (typeof data === 'object')
{
for (const key in data) { if (data.hasOwnProperty(key)) { data[key] = _depthTraverse(data[key], func); } }
}
else
{
data = func(data);
if (Array.isArray(data))
{
for (let cntr = 0; cntr < data.length; cntr++) { _depthTraverse(data[cntr], func, modify); }
}
else if (typeof data === 'object')
{
for (const key in data) { if (data.hasOwnProperty(key)) { _depthTraverse(data[key], func, modify); } }
}
else
{
func(data);
}
}

@@ -203,0 +676,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc