mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-12-29 16:16:02 +00:00
uodate wrap to handle empty items deletion and adding testcases for that feature
This commit is contained in:
@@ -9,8 +9,10 @@ export function wrapList(
|
||||
input: string,
|
||||
splitSeparator: string,
|
||||
joinSeparator: string,
|
||||
deleteEmptyItems: boolean,
|
||||
left: string = '',
|
||||
right: string = ''
|
||||
right: string = '',
|
||||
|
||||
): string {
|
||||
let array: string[];
|
||||
let wrappedArray: string[];
|
||||
@@ -22,6 +24,9 @@ export function wrapList(
|
||||
array = input.split(new RegExp(splitSeparator));
|
||||
break;
|
||||
}
|
||||
if (deleteEmptyItems) {
|
||||
array = array.filter(Boolean);
|
||||
}
|
||||
wrappedArray = wrap(array, left, right);
|
||||
return wrappedArray.join(joinSeparator);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user