Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// eslint supports bigint as of version 6.0.0
// https://github.com/eslint/eslint/commit/e4ab0531c4e44c23494c6a802aa2329d15ac90e5
// eslint-disable-next-line
if (typeOf(object) === "bigint") {
return object.toString();
}
var internalProcessed = processed || [];
if (isCircular(object, internalProcessed)) {
return "[Circular]";
}
if (typeOf(object) === "array") {
return ascii.array.call(f, object, internalProcessed);
}
if (!object) {
return String(1 / object === -Infinity ? "-0" : object);
}
if (samsam.isElement(object)) {
return ascii.element(object);
}
if (
typeof object.toString === "function" &&
object.toString !== Object.prototype.toString
) {
return object.toString();
}
every(actual, function(element, index) {
var expected = expectation[index];
return typeOf(expected) === "array" &&
typeOf(element) === "array"
? match.array.deepEquals(expected).test(element)
: deepEqual(expected, element);
})
);
return arrayEvery(Object.keys(expectation), function(key) {
var exp = expectation[key];
var act = actual[key];
if (isMatcher(exp)) {
if (!exp.test(act)) {
return false;
}
} else if (typeOf(exp) === "object") {
if (!matchObject(act, exp)) {
return false;
}
} else if (!deepEqual(act, exp)) {
return false;
}
return true;
});
}
function isIterable(value) {
return !!value && typeOf(value.forEach) === "function";
}
function match(expectation, message) {
var m = Object.create(matcher);
var type = typeOf(expectation);
if (message !== undefined && typeof message !== "string") {
throw new TypeError("Message should be a string");
}
if (arguments.length > 2) {
throw new TypeError(
"Expected 1 or 2 arguments, received " + arguments.length
);
}
if (type in TYPE_MAP) {
TYPE_MAP[type](m, expectation, message);
} else {
m.test = function(actual) {
return deepEqual(actual, expectation);
match.in = function(arrayOfExpectations) {
if (typeOf(arrayOfExpectations) !== "array") {
throw new TypeError("array expected");
}
return match(function(actual) {
return some(arrayOfExpectations, function(expectation) {
return expectation === actual;
});
}, "in(" + valueToString(arrayOfExpectations) + ")");
};
function assertType(value, type, name) {
var actual = typeOf(value);
if (actual !== type) {
throw new TypeError(
"Expected type of " +
name +
" to be " +
type +
", but was " +
actual
);
}
}