Fix naming of set-theory utils to match convention (#7343)
This commit is contained in:
parent
908e938996
commit
fcc4939075
7 changed files with 39 additions and 39 deletions
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { arrayDiff, arrayMerge, arrayUnion } from "./arrays";
|
||||
import { arrayDiff, arrayUnion, arrayIntersection } from "./arrays";
|
||||
|
||||
type ObjectExcluding<O extends {}, P extends (keyof O)[]> = {[k in Exclude<keyof O, P[number]>]: O[k]};
|
||||
|
||||
|
@ -90,7 +90,7 @@ export function objectHasDiff<O extends {}>(a: O, b: O): boolean {
|
|||
const aKeys = Object.keys(a);
|
||||
const bKeys = Object.keys(b);
|
||||
if (aKeys.length !== bKeys.length) return true;
|
||||
const possibleChanges = arrayUnion(aKeys, bKeys);
|
||||
const possibleChanges = arrayIntersection(aKeys, bKeys);
|
||||
// if the amalgamation of both sets of keys has the a different length to the inputs then there must be a change
|
||||
if (possibleChanges.length !== aKeys.length) return true;
|
||||
|
||||
|
@ -111,7 +111,7 @@ export function objectDiff<O extends {}>(a: O, b: O): Diff<keyof O> {
|
|||
const aKeys = Object.keys(a) as (keyof O)[];
|
||||
const bKeys = Object.keys(b) as (keyof O)[];
|
||||
const keyDiff = arrayDiff(aKeys, bKeys);
|
||||
const possibleChanges = arrayUnion(aKeys, bKeys);
|
||||
const possibleChanges = arrayIntersection(aKeys, bKeys);
|
||||
const changes = possibleChanges.filter(k => a[k] !== b[k]);
|
||||
|
||||
return { changed: changes, added: keyDiff.added, removed: keyDiff.removed };
|
||||
|
@ -128,7 +128,7 @@ export function objectDiff<O extends {}>(a: O, b: O): Diff<keyof O> {
|
|||
*/
|
||||
export function objectKeyChanges<O extends {}>(a: O, b: O): (keyof O)[] {
|
||||
const diff = objectDiff(a, b);
|
||||
return arrayMerge(diff.removed, diff.added, diff.changed);
|
||||
return arrayUnion(diff.removed, diff.added, diff.changed);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue