refactor(core): Extract duplicate utility functions and add unit tests (no-changelog) (#9814)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-06-20 12:09:23 +02:00
committed by GitHub
parent 283d1ca583
commit e4463c62b4
14 changed files with 207 additions and 199 deletions

View File

@@ -9,7 +9,8 @@ import {
type INodeType,
type INodeTypeDescription,
} from 'n8n-workflow';
import { shuffleArray, sortByCode } from './utils';
import { sortByCode } from './utils';
import { shuffleArray } from '@utils/utilities';
export class Sort implements INodeType {
description: INodeTypeDescription = {

View File

@@ -1,13 +1,6 @@
import { NodeVM } from '@n8n/vm2';
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
import { NodeOperationError, randomInt } from 'n8n-workflow';
export const shuffleArray = (array: any[]) => {
for (let i = array.length - 1; i > 0; i--) {
const j = randomInt(i + 1);
[array[i], array[j]] = [array[j], array[i]];
}
};
import { NodeOperationError } from 'n8n-workflow';
const returnRegExp = /\breturn\b/g;
export function sortByCode(