Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return match(function(actual) {
// Comparing lengths is the fastest way to spot a difference before iterating through every item
var sameLength = actual.length === expectation.length;
return (
typeOf(actual) === "array" &&
sameLength &&
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);
})
);
}, "deepEquals([" + iterableToString(expectation) + "])");
};
return match(function(actual) {
if (typeOf(actual) === "object") {
return every(Object.keys(actual), function(key) {
return predicate.test(actual[key]);
});
}
return (
isIterable(actual) &&
every(actual, function(element) {
return predicate.test(element);
})
);
}, "every(" + predicate.message + ")");
};
return match(function(actual) {
if (typeOf(actual) === "object") {
return !every(Object.keys(actual), function(key) {
return !predicate.test(actual[key]);
});
}
return (
isIterable(actual) &&
!every(actual, function(element) {
return !predicate.test(element);
})
);
}, "some(" + predicate.message + ")");
};
return match(function(actual) {
if (typeOf(actual) === "object") {
return every(Object.keys(actual), function(key) {
return predicate.test(actual[key]);
});
}
return (
isIterable(actual) &&
every(actual, function(element) {
return predicate.test(element);
})
);
}, "every(" + predicate.message + ")");
};
return match(function(actual) {
if (typeOf(actual) === "object") {
return !every(Object.keys(actual), function(key) {
return !predicate.test(actual[key]);
});
}
return (
isIterable(actual) &&
!every(actual, function(element) {
return !predicate.test(element);
})
);
}, "some(" + predicate.message + ")");
};
return match(function(actual) {
return (
typeOf(actual) === "array" &&
every(expectation, function(expectedElement, index) {
return actual[index] === expectedElement;
})
);
}, "startsWith([" + iterableToString(expectation) + "])");
};