jest-diff
Advanced tools
Comparing version 27.0.0-next.8 to 27.0.0-next.9
@@ -15,3 +15,2 @@ /** | ||
export { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff }; | ||
declare function diff(a: any, b: any, options?: DiffOptions): string | null; | ||
export default diff; | ||
export declare function diff(a: any, b: any, options?: DiffOptions): string | null; |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.diff = diff; | ||
Object.defineProperty(exports, 'DIFF_DELETE', { | ||
@@ -61,9 +62,8 @@ enumerable: true, | ||
}); | ||
exports.default = void 0; | ||
var _chalk = _interopRequireDefault(require('chalk')); | ||
var _jestGetType = _interopRequireDefault(require('jest-get-type')); | ||
var _jestGetType = require('jest-get-type'); | ||
var _prettyFormat = _interopRequireWildcard(require('pretty-format')); | ||
var _prettyFormat = require('pretty-format'); | ||
@@ -80,44 +80,2 @@ var _cleanupSemantic = require('./cleanupSemantic'); | ||
function _getRequireWildcardCache() { | ||
if (typeof WeakMap !== 'function') return null; | ||
var cache = new WeakMap(); | ||
_getRequireWildcardCache = function () { | ||
return cache; | ||
}; | ||
return cache; | ||
} | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj; | ||
} | ||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) { | ||
return {default: obj}; | ||
} | ||
var cache = _getRequireWildcardCache(); | ||
if (cache && cache.has(obj)) { | ||
return cache.get(obj); | ||
} | ||
var newObj = {}; | ||
var hasPropertyDescriptor = | ||
Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for (var key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor | ||
? Object.getOwnPropertyDescriptor(obj, key) | ||
: null; | ||
if (desc && (desc.get || desc.set)) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) { | ||
cache.set(obj, newObj); | ||
} | ||
return newObj; | ||
} | ||
function _interopRequireDefault(obj) { | ||
@@ -170,3 +128,3 @@ return obj && obj.__esModule ? obj : {default: obj}; | ||
const aType = (0, _jestGetType.default)(a); | ||
const aType = (0, _jestGetType.getType)(a); | ||
let expectedType = aType; | ||
@@ -192,7 +150,7 @@ let omitDifference = false; | ||
if (expectedType !== (0, _jestGetType.default)(b)) { | ||
if (expectedType !== (0, _jestGetType.getType)(b)) { | ||
return ( | ||
' Comparing two different types of values.' + | ||
` Expected ${_chalk.default.green(expectedType)} but ` + | ||
`received ${_chalk.default.red((0, _jestGetType.default)(b))}.` | ||
`received ${_chalk.default.red((0, _jestGetType.getType)(b))}.` | ||
); | ||
@@ -229,4 +187,4 @@ } | ||
function comparePrimitive(a, b, options) { | ||
const aFormat = (0, _prettyFormat.default)(a, FORMAT_OPTIONS); | ||
const bFormat = (0, _prettyFormat.default)(b, FORMAT_OPTIONS); | ||
const aFormat = (0, _prettyFormat.format)(a, FORMAT_OPTIONS); | ||
const bFormat = (0, _prettyFormat.format)(b, FORMAT_OPTIONS); | ||
return aFormat === bFormat | ||
@@ -255,4 +213,4 @@ ? getCommonMessage(_constants.NO_DIFF_MESSAGE, options) | ||
try { | ||
const aCompare = (0, _prettyFormat.default)(a, FORMAT_OPTIONS_0); | ||
const bCompare = (0, _prettyFormat.default)(b, FORMAT_OPTIONS_0); | ||
const aCompare = (0, _prettyFormat.format)(a, FORMAT_OPTIONS_0); | ||
const bCompare = (0, _prettyFormat.format)(b, FORMAT_OPTIONS_0); | ||
@@ -262,4 +220,4 @@ if (aCompare === bCompare) { | ||
} else { | ||
const aDisplay = (0, _prettyFormat.default)(a, FORMAT_OPTIONS); | ||
const bDisplay = (0, _prettyFormat.default)(b, FORMAT_OPTIONS); | ||
const aDisplay = (0, _prettyFormat.format)(a, FORMAT_OPTIONS); | ||
const bDisplay = (0, _prettyFormat.format)(b, FORMAT_OPTIONS); | ||
difference = (0, _diffLines.diffLinesUnified2)( | ||
@@ -279,4 +237,4 @@ aDisplay.split('\n'), | ||
if (difference === undefined || difference === noDiffMessage) { | ||
const aCompare = (0, _prettyFormat.default)(a, FALLBACK_FORMAT_OPTIONS_0); | ||
const bCompare = (0, _prettyFormat.default)(b, FALLBACK_FORMAT_OPTIONS_0); | ||
const aCompare = (0, _prettyFormat.format)(a, FALLBACK_FORMAT_OPTIONS_0); | ||
const bCompare = (0, _prettyFormat.format)(b, FALLBACK_FORMAT_OPTIONS_0); | ||
@@ -286,4 +244,4 @@ if (aCompare === bCompare) { | ||
} else { | ||
const aDisplay = (0, _prettyFormat.default)(a, FALLBACK_FORMAT_OPTIONS); | ||
const bDisplay = (0, _prettyFormat.default)(b, FALLBACK_FORMAT_OPTIONS); | ||
const aDisplay = (0, _prettyFormat.format)(a, FALLBACK_FORMAT_OPTIONS); | ||
const bDisplay = (0, _prettyFormat.format)(b, FALLBACK_FORMAT_OPTIONS); | ||
difference = (0, _diffLines.diffLinesUnified2)( | ||
@@ -308,4 +266,1 @@ aDisplay.split('\n'), | ||
} | ||
var _default = diff; | ||
exports.default = _default; |
{ | ||
"name": "jest-diff", | ||
"version": "27.0.0-next.8", | ||
"version": "27.0.0-next.9", | ||
"repository": { | ||
@@ -19,7 +19,7 @@ "type": "git", | ||
"diff-sequences": "^27.0.0-next.0", | ||
"jest-get-type": "^27.0.0-next.0", | ||
"pretty-format": "^27.0.0-next.8" | ||
"jest-get-type": "^27.0.0-next.9", | ||
"pretty-format": "^27.0.0-next.9" | ||
}, | ||
"devDependencies": { | ||
"@jest/test-utils": "^27.0.0-next.8", | ||
"@jest/test-utils": "^27.0.0-next.9", | ||
"strip-ansi": "^6.0.0" | ||
@@ -33,3 +33,3 @@ }, | ||
}, | ||
"gitHead": "d7ba5030e274b52f029179dfdb860349a36eea37" | ||
"gitHead": "d836f33f98845794b4eae8149548a81ddcfc6521" | ||
} |
@@ -5,3 +5,3 @@ # jest-diff | ||
The default export serializes JavaScript **values**, compares them line-by-line, and returns a string which includes comparison lines. | ||
The `diff` named export serializes JavaScript **values**, compares them line-by-line, and returns a string which includes comparison lines. | ||
@@ -25,5 +25,5 @@ Two named exports compare **strings** character-by-character: | ||
## Usage of default export | ||
## Usage of `diff()` | ||
Given JavaScript **values**, `diffDefault(a, b, options?)` does the following: | ||
Given JavaScript **values**, `diff(a, b, options?)` does the following: | ||
@@ -36,6 +36,6 @@ 1. **serialize** the values as strings using the `pretty-format` package | ||
- `const diffDefault = require('jest-diff').default;` in CommonJS modules | ||
- `import diffDefault from 'jest-diff';` in ECMAScript modules | ||
- `const {diff} = require('jest-diff');` in CommonJS modules | ||
- `import {diff} from 'jest-diff';` in ECMAScript modules | ||
### Example of default export | ||
### Example of `diff()` | ||
@@ -46,3 +46,3 @@ ```js | ||
const difference = diffDefault(a, b); | ||
const difference = diff(a, b); | ||
``` | ||
@@ -68,3 +68,3 @@ | ||
### Edge cases of default export | ||
### Edge cases of `diff()` | ||
@@ -382,3 +382,3 @@ Here are edge cases for the return value: | ||
- `diffDefault(a, b, options)` | ||
- `diff(a, b, options)` | ||
- `diffStringsUnified(a, b, options)` | ||
@@ -461,3 +461,3 @@ - `diffLinesUnified(aLines, bLines, options)` | ||
Because the default export does not display substring differences within lines, formatting can help you see when lines differ by the presence or absence of trailing spaces found by `/\s+$/` regular expression. | ||
Because `diff()` does not display substring differences within lines, formatting can help you see when lines differ by the presence or absence of trailing spaces found by `/\s+$/` regular expression. | ||
@@ -563,3 +563,3 @@ - If change lines have a background color, then you can see trailing spaces. | ||
const difference = diffDefault(a, b, options); | ||
const difference = diff(a, b, options); | ||
``` | ||
@@ -566,0 +566,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85415
1840
Updatedjest-get-type@^27.0.0-next.9
Updatedpretty-format@^27.0.0-next.9