This commit is contained in:
Simon Priet
2021-09-05 22:53:58 +02:00
commit 9e2991e668
17888 changed files with 1263126 additions and 0 deletions

33
node_modules/assertion-error-formatter/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,33 @@
# 2.0.1
* support object errors without stack
* better formatting for errors where the stack does not include the message
# 2.0.0
* support string errors
* update options structure
```js
// Before
{
colorDiffAdded,
colorDiffRemoved,
colorErrorMessage,
inlineDiffs
}
// After
{
colorFns: {
diffAdded,
diffRemoved,
errorMessage,
errorStack
},
inlineDiffs
}
```
# 1.0.1
* Initial release

21
node_modules/assertion-error-formatter/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2016 Charlie Rudolph
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

22
node_modules/assertion-error-formatter/README.md generated vendored Normal file
View File

@@ -0,0 +1,22 @@
# Node Assertion Error Formatter
Format errors to display a diff between the actual and expected
Originally extracted from [mocha](https://github.com/mochajs/mocha)
## Usage
```js
import {format} from 'assertion-error-formatter'
format(error)
```
## API Reference
#### `format(error [, options])`
* `error`: a javascript error
* `options`: An object with the following keys:
* `colorFns`: An object with the keys 'diffAdded', 'diffRemoved', 'errorMessage', 'errorStack'. The values are functions to colorize a string, each defaults to identity.
* `inlineDiff`: boolean (default: false)
* toggle between inline and unified diffs

View File

@@ -0,0 +1,50 @@
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default =
canonicalize;var _has_property = require('./has_property');var _has_property2 = _interopRequireDefault(_has_property);var _type = require('./type');var _type2 = _interopRequireDefault(_type);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function canonicalize(value, stack) {
stack = stack || [];
function withStack(fn) {
stack.push(value);
var result = fn();
stack.pop();
return result;
}
if (stack.indexOf(value) !== -1) {
return '[Circular]';
}
switch ((0, _type2.default)(value)) {
case 'array':
return withStack(function () {
return value.map(function (item) {
return canonicalize(item, stack);
});
});
case 'function':
if (!(0, _has_property2.default)(value)) {
return '[Function]';
}
/* falls through */
case 'object':
return withStack(function () {
var canonicalizedObj = {};
Object.keys(value).sort().map(function (key) {
canonicalizedObj[key] = canonicalize(value[key], stack);
});
return canonicalizedObj;
});
case 'boolean':
case 'buffer':
case 'date':
case 'null':
case 'number':
case 'regexp':
case 'symbol':
case 'undefined':
return value;
default:
return value.toString();}
}

View File

@@ -0,0 +1,8 @@
"use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = hasProperty;function hasProperty(obj) {
for (var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop)) {
return true;
}
}
return false;
}

View File

@@ -0,0 +1,40 @@
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default =
inlineDiff;var _diff = require('diff');var _padRight = require('pad-right');var _padRight2 = _interopRequireDefault(_padRight);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function inlineDiff(actual, expected, colorFns) {
var msg = errorDiff(actual, expected, colorFns);
// linenos
var lines = msg.split('\n');
if (lines.length > 4) {(function () {
var width = String(lines.length).length;
msg = lines.map(function (str, i) {
return (0, _padRight2.default)(i + 1, width, ' ') + '|' + ' ' + str;
}).join('\n');})();
}
// legend
msg = '\n ' +
colorFns.diffRemoved('actual') +
' ' +
colorFns.diffAdded('expected') +
'\n\n' +
msg.replace(/^/gm, ' ') +
'\n';
return msg;
}
function errorDiff(actual, expected, colorFns) {
return (0, _diff.diffWordsWithSpace)(actual, expected).map(function (str) {
if (str.added) {
return colorFns.diffAdded(str.value);
}
if (str.removed) {
return colorFns.diffRemoved(str.value);
}
return str.value;
}).join('');
}

View File

@@ -0,0 +1,79 @@
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default =
jsonStringify;var _repeatString = require('repeat-string');var _repeatString2 = _interopRequireDefault(_repeatString);var _type = require('./type');var _type2 = _interopRequireDefault(_type);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function jsonStringify(object, depth) {
depth = depth || 1;
switch ((0, _type2.default)(object)) {
case 'boolean':
case 'regexp':
case 'symbol':
return object.toString();
case 'null':
case 'undefined':
return '[' + object + ']';
case 'array':
case 'object':
return jsonStringifyProperties(object, depth);
case 'number':
if (object === 0 && 1 / object === -Infinity) {
return '-0';
} else {
return object.toString();
}
case 'date':
return jsonStringifyDate(object);
case 'buffer':
return jsonStringifyBuffer(object, depth);
default:
if (object === '[Function]' || object === '[Circular]') {
return object;
} else {
return JSON.stringify(object); // string
}}
}
function jsonStringifyBuffer(object, depth) {var _object$toJSON =
object.toJSON(),data = _object$toJSON.data;
return '[Buffer: ' + jsonStringify(data, depth) + ']';
}
function jsonStringifyDate(object) {
var str = void 0;
if (isNaN(object.getTime())) {
str = object.toString();
} else {
str = object.toISOString();
}
return '[Date: ' + str + ']';
}
function jsonStringifyProperties(object, depth) {
var space = 2 * depth;
var start = (0, _type2.default)(object) === 'array' ? '[' : '{';
var end = (0, _type2.default)(object) === 'array' ? ']' : '}';
var length = typeof object.length === 'number' ? object.length : Object.keys(object).length;
var addedProperties = 0;
var str = start;
for (var prop in object) {
if (Object.prototype.hasOwnProperty.call(object, prop)) {
addedProperties += 1;
str += '\n' + (0, _repeatString2.default)(' ', space) + (
(0, _type2.default)(object) === 'array' ? '' : '"' + prop + '": ') +
jsonStringify(object[prop], depth + 1) + (
addedProperties === length ? '' : ',');
}
}
if (str.length !== 1) {
str += '\n' + (0, _repeatString2.default)(' ', space - 2);
}
return str + end;
}

View File

@@ -0,0 +1,7 @@
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default =
stringify;var _canonicalize = require('./canonicalize');var _canonicalize2 = _interopRequireDefault(_canonicalize);var _json_stringify = require('./json_stringify');var _json_stringify2 = _interopRequireDefault(_json_stringify);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function stringify(value) {
return (0, _json_stringify2.default)((0, _canonicalize2.default)(value)).replace(/,(\n|$)/g, '$1');
}

View File

@@ -0,0 +1,12 @@
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default = type;function type(value) {
if (value === undefined) {
return 'undefined';
} else if (value === null) {
return 'null';
} else if (typeof Buffer !== 'undefined' && Buffer.isBuffer(value)) {
return 'buffer';
}
return Object.prototype.toString.call(value).
replace(/^\[.+\s(.+?)\]$/, '$1').
toLowerCase();
}

View File

@@ -0,0 +1,33 @@
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.default =
unifiedDiff;var _diff = require('diff');function unifiedDiff(actual, expected, colorFns) {
var indent = ' ';
function cleanUp(line) {
if (line.length === 0) {
return '';
}
if (line[0] === '+') {
return indent + colorFns.diffAdded(line);
}
if (line[0] === '-') {
return indent + colorFns.diffRemoved(line);
}
if (line.match(/\@\@/)) {
return null;
}
if (line.match(/\\ No newline/)) {
return null;
}
return indent + line;
}
function notBlank(line) {
return typeof line !== 'undefined' && line !== null;
}
var msg = (0, _diff.createPatch)('string', actual, expected);
var lines = msg.split('\n').splice(4);
return '\n' + indent +
colorFns.diffAdded('+ expected') + ' ' +
colorFns.diffRemoved('- actual') +
'\n\n' +
lines.map(cleanUp).filter(notBlank).join('\n');
}

76
node_modules/assertion-error-formatter/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
'use strict';Object.defineProperty(exports, "__esModule", { value: true });exports.
format = format;var _inline_diff = require('./helpers/inline_diff');var _inline_diff2 = _interopRequireDefault(_inline_diff);var _stringify = require('./helpers/stringify');var _stringify2 = _interopRequireDefault(_stringify);var _type = require('./helpers/type');var _type2 = _interopRequireDefault(_type);var _unified_diff = require('./helpers/unified_diff');var _unified_diff2 = _interopRequireDefault(_unified_diff);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}function identity(x) {return x;}function format(err, options) {
if (!options) {
options = {};
}
if (!options.colorFns) {
options.colorFns = {};
}
['diffAdded', 'diffRemoved', 'errorMessage', 'errorStack'].forEach(function (key) {
if (!options.colorFns[key]) {
options.colorFns[key] = identity;
}
});
var message = void 0;
if (err.message && typeof err.message.toString === 'function') {
message = err.message + '';
} else if (typeof err.inspect === 'function') {
message = err.inspect() + '';
} else if (typeof err === 'string') {
message = err;
} else {
message = JSON.stringify(err);
}
var stack = err.stack || message;
var startOfMessageIndex = stack.indexOf(message);
if (startOfMessageIndex === -1) {
stack = '\n' + stack;
} else {
var endOfMessageIndex = startOfMessageIndex + message.length;
message = stack.slice(0, endOfMessageIndex);
stack = stack.slice(endOfMessageIndex); // remove message from stack
}
if (err.uncaught) {
message = 'Uncaught ' + message;
}
var actual = err.actual;
var expected = err.expected;
if (err.showDiff !== false && (0, _type2.default)(actual) === (0, _type2.default)(expected) && expected !== undefined) {
if (!((0, _type2.default)(actual) === 'string' && (0, _type2.default)(expected) === 'string')) {
actual = (0, _stringify2.default)(actual);
expected = (0, _stringify2.default)(expected);
}
var match = message.match(/^([^:]+): expected/);
message = options.colorFns.errorMessage(match ? match[1] : message);
if (options.inlineDiff) {
message += (0, _inline_diff2.default)(actual, expected, options.colorFns);
} else {
message += (0, _unified_diff2.default)(actual, expected, options.colorFns);
}
} else {
message = options.colorFns.errorMessage(message);
}
if (stack) {
stack = options.colorFns.errorStack(stack);
}
return message + stack;
}

49
node_modules/assertion-error-formatter/package.json generated vendored Normal file
View File

@@ -0,0 +1,49 @@
{
"name": "assertion-error-formatter",
"version": "2.0.1",
"main": "lib/index.js",
"scripts": {
"build": "babel src -d lib --ignore '**/*_test.js' --retain-lines",
"lint": "yarn run lint-js && yarn run lint-dependencies",
"lint-dependencies": "dependency-lint",
"lint-js": "eslint src/** test/test_helper.js",
"prepublish": "yarn run build",
"test": "yarn run lint && yarn run unit-test",
"unit-test": "mocha src"
},
"repository": {
"type": "git",
"url": "git+https://github.com/charlierudolph/node-assertion-error-formatter.git"
},
"author": {
"name": "Charlie Rudolph",
"email": "charles.w.rudolph@gmail.com"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/charlierudolph/node-assertion-error-formatter/issues"
},
"homepage": "https://github.com/charlierudolph/node-assertion-error-formatter",
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-eslint": "^7.1.1",
"babel-preset-es2015": "^6.18.0",
"babel-register": "^6.18.0",
"chai": "^3.5.0",
"dependency-lint": "^4.3.0",
"eslint": "^3.7.0",
"eslint-plugin-babel": "^4.0.0",
"mocha": "^3.2.0",
"sinon": "^1.17.6",
"sinon-chai": "^2.8.0"
},
"dependencies": {
"diff": "^3.0.0",
"pad-right": "^0.2.2",
"repeat-string": "^1.6.1"
},
"files": [
"lib"
]
}