@trackunit/shared-utils
Advanced tools
Comparing version 0.0.65 to 0.0.66
@@ -642,2 +642,20 @@ 'use strict'; | ||
}; | ||
/** | ||
* Returns an object with only the differences between two input objects. | ||
* Not recursive, only compares first level properties. | ||
*/ | ||
const getFirstLevelObjectPropertyDifferences = (obj1, obj2) => { | ||
return objectEntries(obj1).reduce((diff, [key, value]) => { | ||
// Check if the property exists in obj2. | ||
if (key in obj2) { | ||
const val = obj2[key]; | ||
// Check if obj1's property's value is different from obj2's. | ||
if (val !== value) { | ||
return Object.assign(Object.assign({}, diff), { [key]: val }); | ||
} | ||
} | ||
// Otherwise, just return the previous diff object. | ||
return diff; | ||
}, {}); | ||
}; | ||
@@ -1111,2 +1129,3 @@ /** | ||
exports.getEndOfDay = getEndOfDay; | ||
exports.getFirstLevelObjectPropertyDifferences = getFirstLevelObjectPropertyDifferences; | ||
exports.getISOStringFromDate = getISOStringFromDate; | ||
@@ -1113,0 +1132,0 @@ exports.getMultipleCoordinatesFromGeoJsonObject = getMultipleCoordinatesFromGeoJsonObject; |
@@ -638,2 +638,20 @@ var HoursAndMinutesFormat; | ||
}; | ||
/** | ||
* Returns an object with only the differences between two input objects. | ||
* Not recursive, only compares first level properties. | ||
*/ | ||
const getFirstLevelObjectPropertyDifferences = (obj1, obj2) => { | ||
return objectEntries(obj1).reduce((diff, [key, value]) => { | ||
// Check if the property exists in obj2. | ||
if (key in obj2) { | ||
const val = obj2[key]; | ||
// Check if obj1's property's value is different from obj2's. | ||
if (val !== value) { | ||
return Object.assign(Object.assign({}, diff), { [key]: val }); | ||
} | ||
} | ||
// Otherwise, just return the previous diff object. | ||
return diff; | ||
}, {}); | ||
}; | ||
@@ -1083,2 +1101,2 @@ /** | ||
export { DateTimeFormat, HoursAndMinutesFormat, align, alphabeticallySort, arrayLengthCompare, arrayNotEmpty, booleanCompare, capitalize, convertBlobToBase64, convertMetersToYards, convertYardsToMeters, dateCompare, deleteUndefinedKeys, difference, doNothing, enumFromValue, enumFromValueTypesafe, enumOrUndefinedFromValue, exhaustiveCheck, filterByMultiple, formatAddress, formatCoordinates, fuzzySearch, getDifferenceBetweenDates, getEndOfDay, getISOStringFromDate, getMultipleCoordinatesFromGeoJsonObject, getPointCoordinateFromGeoJsonObject, getResizedDimensions, getStartOfDay, groupBy, groupTinyDataToOthers, hourIntervals, intersection, isArrayEqual, isSorted, isUUID, isValidImage, nonNullable, numberCompare, numberCompareUnknownAfterHighest, objNotEmpty, objectEntries, objectFromEntries, objectKeys, objectValues, pick, removeLeftPadding, resizeBlob, resizeImage, size, stringCompare, stringCompareFromKey, stringNaturalCompare, stripHiddenCharacters, titleCase, toID, toIDs, toUUID, trimIds, trimPath, truthy, unionArraysByKey }; | ||
export { DateTimeFormat, HoursAndMinutesFormat, align, alphabeticallySort, arrayLengthCompare, arrayNotEmpty, booleanCompare, capitalize, convertBlobToBase64, convertMetersToYards, convertYardsToMeters, dateCompare, deleteUndefinedKeys, difference, doNothing, enumFromValue, enumFromValueTypesafe, enumOrUndefinedFromValue, exhaustiveCheck, filterByMultiple, formatAddress, formatCoordinates, fuzzySearch, getDifferenceBetweenDates, getEndOfDay, getFirstLevelObjectPropertyDifferences, getISOStringFromDate, getMultipleCoordinatesFromGeoJsonObject, getPointCoordinateFromGeoJsonObject, getResizedDimensions, getStartOfDay, groupBy, groupTinyDataToOthers, hourIntervals, intersection, isArrayEqual, isSorted, isUUID, isValidImage, nonNullable, numberCompare, numberCompareUnknownAfterHighest, objNotEmpty, objectEntries, objectFromEntries, objectKeys, objectValues, pick, removeLeftPadding, resizeBlob, resizeImage, size, stringCompare, stringCompareFromKey, stringNaturalCompare, stripHiddenCharacters, titleCase, toID, toIDs, toUUID, trimIds, trimPath, truthy, unionArraysByKey }; |
{ | ||
"name": "@trackunit/shared-utils", | ||
"version": "0.0.65", | ||
"version": "0.0.66", | ||
"repository": "https://github.com/Trackunit/manager", | ||
@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE.txt", |
@@ -20,1 +20,6 @@ /** | ||
export declare const pick: <T, K extends keyof T>(obj: T, ...keys: K[]) => Pick<T, K>; | ||
/** | ||
* Returns an object with only the differences between two input objects. | ||
* Not recursive, only compares first level properties. | ||
*/ | ||
export declare const getFirstLevelObjectPropertyDifferences: <TObject extends Record<PropertyKey, unknown>>(obj1: TObject, obj2: TObject) => Partial<TObject>; |
109730
2896