refactor extra code, duplicates, complexity
- refactor array equality check and add tests - remove OperatingSystem.Unknown causing extra logic, return undefined instead - refactor enum validation to share same logic - refactor scripting language factories to share same logic - refactor too many args in runCodeAsync - refactor ScriptCode constructor to reduce complexity - fix writing useless write to member object since another property write always override it
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { sequenceEqual } from '@/application/Common/Array';
|
||||
import { IFunctionCompiler } from '@/application/Parser/Script/Compiler/Function/IFunctionCompiler';
|
||||
import { ISharedFunctionCollection } from '@/application/Parser/Script/Compiler/Function/ISharedFunctionCollection';
|
||||
import { FunctionData } from 'js-yaml-loader!*';
|
||||
@@ -27,15 +28,3 @@ export class FunctionCompilerStub implements IFunctionCompiler {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function sequenceEqual<T>(array1: readonly T[], array2: readonly T[]) {
|
||||
if (array1.length !== array2.length) {
|
||||
return false;
|
||||
}
|
||||
const sortedArray1 = sort(array1);
|
||||
const sortedArray2 = sort(array2);
|
||||
return sortedArray1.every((val, index) => val === sortedArray2[index]);
|
||||
function sort(array: readonly T[]) {
|
||||
return array.slice().sort();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user