motion-master-client 0.0.56 → 0.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/lib/parameter.ts +18 -0
package/package.json
CHANGED
package/src/lib/parameter.ts
CHANGED
|
@@ -168,3 +168,21 @@ export function intersectionParametersWithDifferentValues<T extends Pick<Paramet
|
|
|
168
168
|
return false;
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
|
+
|
|
172
|
+
export interface ParametersComparison<T extends Pick<Parameter, 'index' | 'subindex' | 'value'>, V = T & { valueOther: ParameterValueType }> {
|
|
173
|
+
differences: [T[], T[]];
|
|
174
|
+
intersections: [T[], T[]];
|
|
175
|
+
comparisons: V[],
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function compareParameters<T extends Pick<Parameter, 'index' | 'subindex' | 'value'>>(p1: T[], p2: T[], roundFloats = false): ParametersComparison<T> {
|
|
179
|
+
const d1 = differenceParameters(p1, p2);
|
|
180
|
+
const d2 = differenceParameters(p2, p1);
|
|
181
|
+
|
|
182
|
+
const i1 = intersectionParametersWithDifferentValues(p1, p2, roundFloats);
|
|
183
|
+
const i2 = intersectionParametersWithDifferentValues(p2, p1, roundFloats);
|
|
184
|
+
|
|
185
|
+
const comparisons = i1.map((p, index) => ({ ...p, valueOther: i2[index].value }));
|
|
186
|
+
|
|
187
|
+
return { differences: [d1, d2], intersections: [i1, i2], comparisons };
|
|
188
|
+
}
|