本文整理匯總了TypeScript中json8.equal函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript equal函數的具體用法?TypeScript equal怎麽用?TypeScript equal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了equal函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: isEqualTo
isEqualTo(expected: any) {
if (!json8.equal(this.actual, expected)) {
throw new AssertionError({
message: prettyDiff(JSON.parse(JSON.stringify(this.actual, jsonReplacer)), JSON.parse(JSON.stringify(expected, jsonReplacer)))
})
}
}
示例2: isEqualTo
isEqualTo(expected: any) {
if (!json8.equal(this.actual, expected)) {
const actualJson = JSON.stringify(this.actual, jsonReplacer, 2)
const expectedJson = JSON.stringify(expected, jsonReplacer, 2)
throw new AssertionError({
message: `Expected \n${expectedJson}\n\nis not equal to\n\n${actualJson}\n\n${prettyDiff(JSON.parse(actualJson), JSON.parse(expectedJson))}`,
actual: this.actual,
expected: expected,
})
}
}
示例3: compare
function compare(actual: any, expected: any, not: boolean = false) {
if (json8.equal(actual, expected) === not) {
const actualJson = JSON.stringify(actual, jsonReplacer, 2)
const expectedJson = JSON.stringify(expected, jsonReplacer, 2)
const stack = new Error().stack
throw new AssertionError({
message: `Expected \n${expectedJson}\n\nis not equal to\n\n${actualJson}\n\n${prettyDiff(JSON.parse(expectedJson), JSON.parse(actualJson))}\n${stack.split("\n")[3].trim()}`,
actual: actual,
expected: expected,
})
}
}