You've already forked obsidian-visualiser
Try to add character editor inside the character sheet
This commit is contained in:
@@ -73,6 +73,38 @@ export function padRight(text: string, pad: string, length: number): string
|
||||
{
|
||||
return pad.repeat(length - text.length).concat(text);
|
||||
}
|
||||
export function shallowEquals(a: any, b: any): boolean
|
||||
{
|
||||
if(a === b) return true;
|
||||
|
||||
if(a && b && typeof a == 'object' && typeof b == 'object')
|
||||
{
|
||||
if (a.constructor !== b.constructor) return false;
|
||||
|
||||
let i, keys;
|
||||
if (Array.isArray(a))
|
||||
{
|
||||
if (a.length != b.length) return false;
|
||||
for (i = a.length; i-- !== 0;)
|
||||
if (!b.includes(a[i])) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
||||
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
||||
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
||||
|
||||
keys = Object.keys(a) as Array<keyof typeof a>;
|
||||
if (keys.length !== Object.keys(b).length) return false;
|
||||
|
||||
for (i = keys.length; i-- !== 0;)
|
||||
if (!Object.prototype.hasOwnProperty.call(b, keys[i]!) || a[keys[i]!] !== b[keys[i]!]) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return a !== a && b !== b;
|
||||
}
|
||||
export function deepEquals(a: any, b: any): boolean
|
||||
{
|
||||
if(a === b) return true;
|
||||
@@ -81,12 +113,11 @@ export function deepEquals(a: any, b: any): boolean
|
||||
{
|
||||
if (a.constructor !== b.constructor) return false;
|
||||
|
||||
let length, i, keys;
|
||||
let i, keys;
|
||||
if (Array.isArray(a))
|
||||
{
|
||||
length = a.length;
|
||||
if (length != b.length) return false;
|
||||
for (i = length; i-- !== 0;)
|
||||
if (a.length != b.length) return false;
|
||||
for (i = a.length; i-- !== 0;)
|
||||
if (!deepEquals(a[i], b[i])) return false;
|
||||
return true;
|
||||
}
|
||||
@@ -96,13 +127,12 @@ export function deepEquals(a: any, b: any): boolean
|
||||
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
||||
|
||||
keys = Object.keys(a) as Array<keyof typeof a>;
|
||||
length = keys.length;
|
||||
if (length !== Object.keys(b).length) return false;
|
||||
if (keys.length !== Object.keys(b).length) return false;
|
||||
|
||||
for (i = length; i-- !== 0;)
|
||||
for (i = keys.length; i-- !== 0;)
|
||||
if (!Object.prototype.hasOwnProperty.call(b, keys[i]!)) return false;
|
||||
|
||||
for (i = length; i-- !== 0;)
|
||||
for (i = keys.length; i-- !== 0;)
|
||||
if(!deepEquals(a[keys[i]!], b[keys[i]!])) return false;
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user