Merge branch 'main' into feature/log-viewer
This commit is contained in:
@@ -1,34 +1,30 @@
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { createObservablePart } from "./create-observable-part.method";
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { createObservablePart } from './create-observable-part.method';
|
||||
|
||||
// TODO: Should this handle array as well?
|
||||
function deepFreeze<T>(inObj: T): T {
|
||||
if(inObj != null && typeof inObj === 'object') {
|
||||
if (inObj != null && typeof inObj === 'object') {
|
||||
Object.freeze(inObj);
|
||||
|
||||
Object.getOwnPropertyNames(inObj)?.forEach(function (prop) {
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
if ((inObj as any).hasOwnProperty(prop)
|
||||
&& (inObj as any)[prop] != null
|
||||
&& typeof (inObj as any)[prop] === 'object'
|
||||
&& !Object.isFrozen((inObj as any)[prop])) {
|
||||
deepFreeze((inObj as any)[prop]);
|
||||
}
|
||||
if (
|
||||
// eslint-disable-next-line no-prototype-builtins
|
||||
(inObj as any).hasOwnProperty(prop) &&
|
||||
(inObj as any)[prop] != null &&
|
||||
typeof (inObj as any)[prop] === 'object' &&
|
||||
!Object.isFrozen((inObj as any)[prop])
|
||||
) {
|
||||
deepFreeze((inObj as any)[prop]);
|
||||
}
|
||||
});
|
||||
}
|
||||
return inObj;
|
||||
}
|
||||
|
||||
|
||||
export function naiveObjectComparison(objOne: any, objTwo: any): boolean {
|
||||
return JSON.stringify(objOne) === JSON.stringify(objTwo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export type MappingFunction<T, R> = (mappable: T) => R;
|
||||
export type MemoizationFunction<R> = (previousResult: R, currentResult: R) => boolean;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user