@sinonjs/samsam
Advanced tools
Comparing version 8.0.0 to 8.0.1
@@ -252,3 +252,3 @@ # samsam | ||
}, | ||
"Yeah!" | ||
"Yeah!", | ||
); // true | ||
@@ -282,3 +282,3 @@ ``` | ||
}, | ||
/yeah/ | ||
/yeah/, | ||
); // true | ||
@@ -301,3 +301,3 @@ samsam.match(234, /[a-z]/); // false | ||
}, | ||
42 | ||
42, | ||
); // true | ||
@@ -334,3 +334,3 @@ samsam.match(234, 1234); // false | ||
return true; | ||
} | ||
}, | ||
); | ||
@@ -374,3 +374,3 @@ | ||
name: "Chris", | ||
} | ||
}, | ||
); | ||
@@ -377,0 +377,0 @@ |
@@ -47,3 +47,3 @@ "use strict"; | ||
throw new TypeError( | ||
`Expected 1 or 2 arguments, received ${arguments.length}` | ||
`Expected 1 or 2 arguments, received ${arguments.length}`, | ||
); | ||
@@ -93,5 +93,8 @@ } | ||
createMatcher.same = function (expectation) { | ||
return createMatcher(function (actual) { | ||
return expectation === actual; | ||
}, `same(${valueToString(expectation)})`); | ||
return createMatcher( | ||
function (actual) { | ||
return expectation === actual; | ||
}, | ||
`same(${valueToString(expectation)})`, | ||
); | ||
}; | ||
@@ -104,7 +107,10 @@ | ||
return createMatcher(function (actual) { | ||
return some(arrayOfExpectations, function (expectation) { | ||
return expectation === actual; | ||
}); | ||
}, `in(${valueToString(arrayOfExpectations)})`); | ||
return createMatcher( | ||
function (actual) { | ||
return some(arrayOfExpectations, function (expectation) { | ||
return expectation === actual; | ||
}); | ||
}, | ||
`in(${valueToString(arrayOfExpectations)})`, | ||
); | ||
}; | ||
@@ -131,8 +137,11 @@ | ||
"type", | ||
"[Symbol.hasInstance]" | ||
"[Symbol.hasInstance]", | ||
); | ||
} | ||
return createMatcher(function (actual) { | ||
return actual instanceof type; | ||
}, `instanceOf(${functionName(type) || objectToString(type)})`); | ||
return createMatcher( | ||
function (actual) { | ||
return actual instanceof type; | ||
}, | ||
`instanceOf(${functionName(type) || objectToString(type)})`, | ||
); | ||
}; | ||
@@ -266,53 +275,65 @@ | ||
createMatcher.array.deepEquals = function (expectation) { | ||
return createMatcher(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" | ||
? createMatcher.array.deepEquals(expected).test(element) | ||
: deepEqual(expected, element); | ||
}) | ||
); | ||
}, `deepEquals([${iterableToString(expectation)}])`); | ||
return createMatcher( | ||
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" | ||
? createMatcher.array.deepEquals(expected).test(element) | ||
: deepEqual(expected, element); | ||
}) | ||
); | ||
}, | ||
`deepEquals([${iterableToString(expectation)}])`, | ||
); | ||
}; | ||
createMatcher.array.startsWith = function (expectation) { | ||
return createMatcher(function (actual) { | ||
return ( | ||
typeOf(actual) === "array" && | ||
every(expectation, function (expectedElement, index) { | ||
return actual[index] === expectedElement; | ||
}) | ||
); | ||
}, `startsWith([${iterableToString(expectation)}])`); | ||
return createMatcher( | ||
function (actual) { | ||
return ( | ||
typeOf(actual) === "array" && | ||
every(expectation, function (expectedElement, index) { | ||
return actual[index] === expectedElement; | ||
}) | ||
); | ||
}, | ||
`startsWith([${iterableToString(expectation)}])`, | ||
); | ||
}; | ||
createMatcher.array.endsWith = function (expectation) { | ||
return createMatcher(function (actual) { | ||
// This indicates the index in which we should start matching | ||
var offset = actual.length - expectation.length; | ||
return createMatcher( | ||
function (actual) { | ||
// This indicates the index in which we should start matching | ||
var offset = actual.length - expectation.length; | ||
return ( | ||
typeOf(actual) === "array" && | ||
every(expectation, function (expectedElement, index) { | ||
return actual[offset + index] === expectedElement; | ||
}) | ||
); | ||
}, `endsWith([${iterableToString(expectation)}])`); | ||
return ( | ||
typeOf(actual) === "array" && | ||
every(expectation, function (expectedElement, index) { | ||
return actual[offset + index] === expectedElement; | ||
}) | ||
); | ||
}, | ||
`endsWith([${iterableToString(expectation)}])`, | ||
); | ||
}; | ||
createMatcher.array.contains = function (expectation) { | ||
return createMatcher(function (actual) { | ||
return ( | ||
typeOf(actual) === "array" && | ||
every(expectation, function (expectedElement) { | ||
return arrayIndexOf(actual, expectedElement) !== -1; | ||
}) | ||
); | ||
}, `contains([${iterableToString(expectation)}])`); | ||
return createMatcher( | ||
function (actual) { | ||
return ( | ||
typeOf(actual) === "array" && | ||
every(expectation, function (expectedElement) { | ||
return arrayIndexOf(actual, expectedElement) !== -1; | ||
}) | ||
); | ||
}, | ||
`contains([${iterableToString(expectation)}])`, | ||
); | ||
}; | ||
@@ -323,24 +344,32 @@ | ||
createMatcher.map.deepEquals = function mapDeepEquals(expectation) { | ||
return createMatcher(function (actual) { | ||
// Comparing lengths is the fastest way to spot a difference before iterating through every item | ||
var sameLength = actual.size === expectation.size; | ||
return ( | ||
typeOf(actual) === "map" && | ||
sameLength && | ||
every(actual, function (element, key) { | ||
return expectation.has(key) && expectation.get(key) === element; | ||
}) | ||
); | ||
}, `deepEquals(Map[${iterableToString(expectation)}])`); | ||
return createMatcher( | ||
function (actual) { | ||
// Comparing lengths is the fastest way to spot a difference before iterating through every item | ||
var sameLength = actual.size === expectation.size; | ||
return ( | ||
typeOf(actual) === "map" && | ||
sameLength && | ||
every(actual, function (element, key) { | ||
return ( | ||
expectation.has(key) && expectation.get(key) === element | ||
); | ||
}) | ||
); | ||
}, | ||
`deepEquals(Map[${iterableToString(expectation)}])`, | ||
); | ||
}; | ||
createMatcher.map.contains = function mapContains(expectation) { | ||
return createMatcher(function (actual) { | ||
return ( | ||
typeOf(actual) === "map" && | ||
every(expectation, function (element, key) { | ||
return actual.has(key) && actual.get(key) === element; | ||
}) | ||
); | ||
}, `contains(Map[${iterableToString(expectation)}])`); | ||
return createMatcher( | ||
function (actual) { | ||
return ( | ||
typeOf(actual) === "map" && | ||
every(expectation, function (element, key) { | ||
return actual.has(key) && actual.get(key) === element; | ||
}) | ||
); | ||
}, | ||
`contains(Map[${iterableToString(expectation)}])`, | ||
); | ||
}; | ||
@@ -351,24 +380,30 @@ | ||
createMatcher.set.deepEquals = function setDeepEquals(expectation) { | ||
return createMatcher(function (actual) { | ||
// Comparing lengths is the fastest way to spot a difference before iterating through every item | ||
var sameLength = actual.size === expectation.size; | ||
return ( | ||
typeOf(actual) === "set" && | ||
sameLength && | ||
every(actual, function (element) { | ||
return expectation.has(element); | ||
}) | ||
); | ||
}, `deepEquals(Set[${iterableToString(expectation)}])`); | ||
return createMatcher( | ||
function (actual) { | ||
// Comparing lengths is the fastest way to spot a difference before iterating through every item | ||
var sameLength = actual.size === expectation.size; | ||
return ( | ||
typeOf(actual) === "set" && | ||
sameLength && | ||
every(actual, function (element) { | ||
return expectation.has(element); | ||
}) | ||
); | ||
}, | ||
`deepEquals(Set[${iterableToString(expectation)}])`, | ||
); | ||
}; | ||
createMatcher.set.contains = function setContains(expectation) { | ||
return createMatcher(function (actual) { | ||
return ( | ||
typeOf(actual) === "set" && | ||
every(expectation, function (element) { | ||
return actual.has(element); | ||
}) | ||
); | ||
}, `contains(Set[${iterableToString(expectation)}])`); | ||
return createMatcher( | ||
function (actual) { | ||
return ( | ||
typeOf(actual) === "set" && | ||
every(expectation, function (element) { | ||
return actual.has(element); | ||
}) | ||
); | ||
}, | ||
`contains(Set[${iterableToString(expectation)}])`, | ||
); | ||
}; | ||
@@ -375,0 +410,0 @@ |
@@ -19,3 +19,3 @@ "use strict"; | ||
throw new TypeError( | ||
`Expected type of ${name} to be ${type}, but was ${actual}` | ||
`Expected type of ${name} to be ${type}, but was ${actual}`, | ||
); | ||
@@ -22,0 +22,0 @@ } |
@@ -9,2 +9,3 @@ "use strict"; | ||
var identical = require("../identical"); | ||
var isMatcher = require("./is-matcher"); | ||
@@ -45,2 +46,5 @@ | ||
} else if (typeOf(exp) === "object") { | ||
if (identical(exp, act)) { | ||
return true; | ||
} | ||
if (!matchObject(act, exp, matcher)) { | ||
@@ -47,0 +51,0 @@ return false; |
@@ -20,3 +20,3 @@ "use strict"; | ||
throw new TypeError( | ||
"createSet can be called with either no arguments or an Array" | ||
"createSet can be called with either no arguments or an Array", | ||
); | ||
@@ -23,0 +23,0 @@ } |
@@ -70,3 +70,3 @@ "use strict"; | ||
actualPath, | ||
expectationPath | ||
expectationPath, | ||
) { | ||
@@ -144,3 +144,3 @@ // If both are matchers they must be the same instance in order to be | ||
expectationKeys, | ||
expectationSymbols | ||
expectationSymbols, | ||
); | ||
@@ -294,3 +294,3 @@ | ||
newActualPath, | ||
newExpectationPath | ||
newExpectationPath, | ||
); | ||
@@ -297,0 +297,0 @@ }); |
@@ -73,3 +73,3 @@ "use strict"; | ||
valueToString(object).toLowerCase(), | ||
matcherOrValue.toLowerCase() | ||
matcherOrValue.toLowerCase(), | ||
) >= 0 | ||
@@ -106,3 +106,3 @@ ); | ||
throw new Error( | ||
"The JavaScript engine does not support Array.from and cannot reliably do value comparison of Map instances" | ||
"The JavaScript engine does not support Array.from and cannot reliably do value comparison of Map instances", | ||
); | ||
@@ -116,3 +116,3 @@ } | ||
Array.from(matcherOrValue), | ||
match | ||
match, | ||
) | ||
@@ -119,0 +119,0 @@ ); |
{ | ||
"name": "@sinonjs/samsam", | ||
"version": "8.0.0", | ||
"version": "8.0.1", | ||
"description": "Value identification and comparison functions", | ||
@@ -47,27 +47,27 @@ "homepage": "http://sinonjs.github.io/samsam/", | ||
"dependencies": { | ||
"@sinonjs/commons": "^2.0.0", | ||
"@sinonjs/commons": "^3.0.1", | ||
"lodash.get": "^4.4.2", | ||
"type-detect": "^4.0.8" | ||
"type-detect": "^4.1.0" | ||
}, | ||
"devDependencies": { | ||
"@sinonjs/eslint-config": "^4.0.6", | ||
"@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.0", | ||
"@sinonjs/referee": "^9.1.1", | ||
"@studio/changes": "^2.2.0", | ||
"@sinonjs/eslint-config": "^5.0.3", | ||
"@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.1", | ||
"@sinonjs/referee": "^11.0.1", | ||
"@studio/changes": "^3.0.0", | ||
"benchmark": "^2.1.4", | ||
"husky": "^8.0.0", | ||
"jquery": "^3.4.1", | ||
"jsdoc": "^3.6.11", | ||
"jsdom": "^16.2.0", | ||
"husky": "^9.1.6", | ||
"jquery": "^3.7.1", | ||
"jsdoc": "^4.0.3", | ||
"jsdom": "^25.0.0", | ||
"jsdom-global": "^3.0.2", | ||
"lint-staged": "^10.0.7", | ||
"lint-staged": "^15.2.10", | ||
"microtime": "^3.1.1", | ||
"mocha": "^10.1.0", | ||
"mocha": "^10.7.3", | ||
"mochify": "^9.2.0", | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.7.1", | ||
"nyc": "^17.0.0", | ||
"prettier": "^3.3.3", | ||
"proxyquire": "^2.1.3", | ||
"proxyquire-universal": "^2.1.0", | ||
"proxyquire-universal": "^3.0.1", | ||
"proxyquireify": "^3.2.1", | ||
"typescript": "^4.8.4" | ||
"typescript": "^5.6.2" | ||
}, | ||
@@ -74,0 +74,0 @@ "nyc": { |
@@ -13,6 +13,6 @@ export = createMatcher; | ||
export { isMatcher }; | ||
export const any: any; | ||
export const defined: any; | ||
export const truthy: any; | ||
export const falsy: any; | ||
export let any: any; | ||
export let defined: any; | ||
export let truthy: any; | ||
export let falsy: any; | ||
export function same(expectation: any): any; | ||
@@ -23,4 +23,4 @@ function _in(arrayOfExpectations: any): any; | ||
export function instanceOf(type: any): any; | ||
export const has: any; | ||
export const hasOwn: any; | ||
export let has: any; | ||
export let hasOwn: any; | ||
export function hasNested(property: any, value: any, ...args: any[]): any; | ||
@@ -30,14 +30,14 @@ export function json(value: any): any; | ||
export function some(predicate: any): any; | ||
export const array: any; | ||
export const map: any; | ||
export const set: any; | ||
export const bool: any; | ||
export const number: any; | ||
export const string: any; | ||
export const object: any; | ||
export const func: any; | ||
export const regexp: any; | ||
export const date: any; | ||
export const symbol: any; | ||
export let array: any; | ||
export let map: any; | ||
export let set: any; | ||
export let bool: any; | ||
export let number: any; | ||
export let string: any; | ||
export let object: any; | ||
export let func: any; | ||
export let regexp: any; | ||
export let date: any; | ||
export let symbol: any; | ||
} | ||
import isMatcher = require("./create-matcher/is-matcher"); |
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
86625
1771
+ Added@sinonjs/commons@3.0.1(transitive)
- Removed@sinonjs/commons@2.0.0(transitive)
Updated@sinonjs/commons@^3.0.1
Updatedtype-detect@^4.1.0