Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const toHaveObjectMatcher = (received: any, propPath: string) =>
createResult({
message: () => `expected ${propPath} of ${received} to be object`,
notMessage: () => `expected ${propPath} of ${received} not to be object`,
pass: isObject(getIn(propPath.split('.'), received))
});
const isBranch = (locator: ILocator): boolean => isObject(unwrap(locator)) || isArray(unwrap(locator));
export const toBeObjectMatcher = (received: any) =>
createResult({
message: () => `expected ${received} to be an object`,
notMessage: () => `expected ${received} not to be an object`,
pass: isObject(received)
});
const iterator = (value: any, path: PropName[]) => {
memo = fn(memo, path, value);
if (isArray(value)) {
for (let i = 0, len = value.length; i < len; i++) {
iterator(value[i], path.concat(i));
}
} else if (isObject(value)) {
for (const key in value) {
if (value.hasOwnProperty(key)) {
iterator(value[key], path.concat(key));
}
}
}
return memo;
};
return iterator(collection, []);
const mutateDescendant = (memo: any[], path: PropName[]): any[] => {
if (path.length) {
const clone = JSON.parse(original);
const locator = locateDescendant(path, clone);
if (isObject(locator.owner)) {
mutateObject(locator as IObjectLocator);
} else if (isArray(locator.owner)) {
mutateArray(locator as IArrayLocator);
}
if (JSON.stringify(clone) !== original) {
memo.push(clone);
}
}
return memo;
};
return deepReduce(collection, mutateDescendant, getInitialValue());