perf: switch from lodash's isEqual to fast-equals

Way faster and maintained library: https://github.com/planttheidea/fast-equals

Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
This commit is contained in:
Fernando Fernández 2024-01-17 11:29:08 +01:00
parent 140e6f29c1
commit 590cdd8235
3 changed files with 12 additions and 2 deletions

View File

@ -29,6 +29,7 @@
"date-fns": "3.2.0",
"destr": "2.0.2",
"dompurify": "3.0.8",
"fast-equals": "5.0.1",
"hls.js": "1.5.1",
"jassub": "1.7.15",
"lodash-es": "4.17.21",

View File

@ -8,7 +8,7 @@ import { isNil } from '@/utils/validation';
import type { Api } from '@jellyfin/sdk';
import type { BaseItemDto, BaseItemDtoQueryResult } from '@jellyfin/sdk/lib/generated-client';
import type { AxiosResponse } from 'axios';
import { isEqual } from 'lodash-es';
import { deepEqual } from 'fast-equals';
import { computed, effectScope, getCurrentScope, isRef, shallowRef, toValue, unref, watch, type ComputedRef, type Ref } from 'vue';
/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return */
@ -288,7 +288,7 @@ function _sharedInternalLogic<T extends Record<K, (...args: any[]) => any>, K ex
/**
* Does a deep comparison to avoid useless double requests
*/
if (!normalizedArgs.every((a, index) => isEqual(a, toValue(oldVal?.[index])))) {
if (!normalizedArgs.every((a, index) => deepEqual(a, toValue(oldVal?.[index])))) {
argsRef.value = normalizedArgs;
await runNormally();
}

9
package-lock.json generated
View File

@ -31,6 +31,7 @@
"date-fns": "3.2.0",
"destr": "2.0.2",
"dompurify": "3.0.8",
"fast-equals": "5.0.1",
"hls.js": "1.5.1",
"jassub": "1.7.15",
"lodash-es": "4.17.21",
@ -4211,6 +4212,14 @@
"integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==",
"dev": true
},
"node_modules/fast-equals": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/fast-equals/-/fast-equals-5.0.1.tgz",
"integrity": "sha512-WF1Wi8PwwSY7/6Kx0vKXtw8RwuSGoM1bvDaJbu7MxDlR1vovZjIAKrnzyrThgAjm6JDTu0fVgWXDlMGspodfoQ==",
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/fast-glob": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz",