Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
operateGroup(group, operation, force = false) {
const newGroup = group.clone().merge(operation, true /* all props */);
const reference = group.clone();
if (force) {
// to force the properties being sent, we need to reset them on the reference
const inverseOperation = objects_1.composeObject(objects_1.entries(operation)
.map(([key, value]) => {
switch (typeof value) {
case "number": return [key, Number.NaN];
case "boolean": return [key, !value];
default: return [key, null];
}
}));
reference.merge(inverseOperation, true);
}
return this.updateResource(`${endpoints_1.endpoints.groups}/${group.instanceId}`, newGroup, reference);
}
/**
export function invertOperation>(
operation: T,
): T {
return composeObject(
entries(operation).map(([key, value]) => {
switch (typeof value) {
case "number":
return [key, Number.NaN] as [string, number];
case "boolean":
return [key, !value] as [string, boolean];
default:
return [key, null] as [string, any];
}
}),
) as T;
}