Skip to content

Commit 382798b

Browse files
author
Roman Snapko
committed
Add indexToAlphabetical function to convert numeric index to alphabetical label
1 parent 6265549 commit 382798b

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

packages/shared/src/lib/flows/flow-helper.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,19 @@ function doesActionHaveChildren(
10991099
return false;
11001100
}
11011101

1102+
/**
1103+
* Converts a zero-based numeric index into a lowercase alphabetical label.
1104+
* Similar to spreadsheet column naming but using lowercase letters:
1105+
* 0 -> "a", 25 -> "z", 26 -> "aa", 27 -> "ab", and so on.
1106+
*
1107+
* @param index - Zero-based integer to convert.
1108+
* @returns Alphabetical label corresponding to the index.
1109+
* @example
1110+
* indexToAlphabetical(0) // "a"
1111+
* indexToAlphabetical(25) // "z"
1112+
* indexToAlphabetical(26) // "aa"
1113+
* indexToAlphabetical(701) // "zz"
1114+
*/
11021115
function indexToAlphabetical(index: number): string {
11031116
let n = index + 1;
11041117
let result = '';

0 commit comments

Comments
 (0)