fix(core): update
This commit is contained in:
		
							
								
								
									
										69
									
								
								ts/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								ts/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,69 @@
 | 
			
		||||
import * as plugins from './smartobject.plugins';
 | 
			
		||||
 | 
			
		||||
export interface IObjectCompareResult {
 | 
			
		||||
  presentInBothProperties: string[];
 | 
			
		||||
  missingProperties: string[];
 | 
			
		||||
  additionalProperties: string[];
 | 
			
		||||
  nulledProperties: string[];
 | 
			
		||||
  undefinedProperties: string[];
 | 
			
		||||
  divergingProperties: string[];
 | 
			
		||||
  equalProperties: string[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const compareObjects = (referenceObjectArg: any, comparisonObjectArg: any): IObjectCompareResult => {
 | 
			
		||||
  const returnComparisonObject = {
 | 
			
		||||
    missingProperties: [],
 | 
			
		||||
    additionalProperties: [],
 | 
			
		||||
    presentInBothProperties: [],
 | 
			
		||||
    nulledProperties: [],
 | 
			
		||||
    undefinedProperties: [],
 | 
			
		||||
    divergingProperties: [],
 | 
			
		||||
    equalProperties: [],
 | 
			
		||||
  };
 | 
			
		||||
  
 | 
			
		||||
  const allProperties = Object.keys(referenceObjectArg).concat(Object.keys(comparisonObjectArg));
 | 
			
		||||
  for (const currentProperty of allProperties) {
 | 
			
		||||
    // lets find presentInBothProperties
 | 
			
		||||
    if (referenceObjectArg[currentProperty] && comparisonObjectArg[currentProperty]) {
 | 
			
		||||
      returnComparisonObject.presentInBothProperties.push(currentProperty);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // lets find missingProperties
 | 
			
		||||
    if (referenceObjectArg[currentProperty] && !comparisonObjectArg[currentProperty]) {
 | 
			
		||||
      returnComparisonObject.missingProperties.push(currentProperty);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // lets find additionalProperties
 | 
			
		||||
    if (!referenceObjectArg[currentProperty] && comparisonObjectArg[currentProperty]) {
 | 
			
		||||
      returnComparisonObject.additionalProperties.push(currentProperty);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // lets find nulledProperties
 | 
			
		||||
    if (comparisonObjectArg[currentProperty] === null) {
 | 
			
		||||
      returnComparisonObject.nulledProperties.push(currentProperty);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // lets find undefinedProperties
 | 
			
		||||
    if (comparisonObjectArg[currentProperty] === undefined) {
 | 
			
		||||
      returnComparisonObject.undefinedProperties.push(currentProperty);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // lets find divergingProperties
 | 
			
		||||
    if (JSON.stringify(referenceObjectArg[currentProperty]) !== JSON.stringify(comparisonObjectArg[currentProperty])) {
 | 
			
		||||
      returnComparisonObject.divergingProperties.push(currentProperty);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // lets find equalProperties
 | 
			
		||||
    if (JSON.stringify(referenceObjectArg[currentProperty]) === JSON.stringify(comparisonObjectArg[currentProperty])) {
 | 
			
		||||
      returnComparisonObject.equalProperties.push(currentProperty);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  for (const currentProperty of Object.keys(returnComparisonObject)) {
 | 
			
		||||
    const propertySet = new Set(returnComparisonObject[currentProperty]);
 | 
			
		||||
    const uniqueArray = [...propertySet];
 | 
			
		||||
    returnComparisonObject[currentProperty] = uniqueArray;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return returnComparisonObject;
 | 
			
		||||
};
 | 
			
		||||
							
								
								
									
										2
									
								
								ts/smartobject.plugins.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								ts/smartobject.plugins.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
			
		||||
const removeme = {};
 | 
			
		||||
export { removeme };
 | 
			
		||||
		Reference in New Issue
	
	Block a user