UNPKG

@rnaga/wp-node

Version:

👉 **[View Full Documentation at rnaga.github.io/wp-node →](https://rnaga.github.io/wp-node/)**

24 lines (23 loc) • 957 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.diffStringArray = exports.diffObject = void 0; const deep_object_diff_1 = require("deep-object-diff"); const diffObject = (a, b) => { const result = (0, deep_object_diff_1.diff)(a, b); if (typeof result === "object") { return Object.assign({}, result); } return {}; }; exports.diffObject = diffObject; const diffStringArray = (a = [], b = []) => { // Ensure both inputs are arrays const arrayA = Array.isArray(a) ? a : [a]; const arrayB = Array.isArray(b) ? b : [b]; // Find elements in A not in B and elements in B not in A const diffFromAtoB = arrayA.filter((item) => !arrayB.includes(item)); const diffFromBtoA = arrayB.filter((item) => !arrayA.includes(item)); // Combine and return the unique results return Array.from(new Set([...diffFromAtoB, ...diffFromBtoA])); }; exports.diffStringArray = diffStringArray;