Skip to content

Commit

Permalink
add documentation to the helper functions
Browse files Browse the repository at this point in the history
addresse edge case on compareKeys
  • Loading branch information
Ragnar-Oock committed Dec 4, 2020
1 parent 15cdd51 commit 87564dd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/helpers/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@ export function prettyLog(module, tag, message, styles) {
}
}


/**
* compare to objects and determine if they are similar or not
* @param {Object} requiredKeys first set of key to compare
* @param {Object} providedKeys second set of key to compare
*/
export function compareKeys(requiredKeys, providedKeys) {
try {
let keysAreIdenticals = false;
const _requiredKeys = Object.entries(requiredKeys);

// if key number are dissymilar the objects are differents
if (_requiredKeys.length !== Object.entries(providedKeys).length) {
return false;
}

_requiredKeys.some(entry => {
const key = entry[0];

Expand All @@ -43,6 +54,11 @@ export function compareKeys(requiredKeys, providedKeys) {
}
}

/**
* Compare tow object and return the key that differs
* @param {Object} requiredKeys reference object
* @param {Object} providedKeys Object to be tested
*/
export function getDiffKeys(requiredKeys, providedKeys) {
try {
const diffKeys = [];
Expand Down

0 comments on commit 87564dd

Please sign in to comment.