In src/helpers/repeat.ts, the repeat helper parses the user-provided count argument using Number.parseInt(rawNum) and stores the result in num. However, the subsequent for loop incorrectly uses the original rawNum (a string) in the comparison i < rawNum instead of the parsed integer num.
This works accidentally due to JavaScript's implicit type coercion in the < operator (string is coerced to number), but it is semantically incorrect and could lead to unexpected behavior with edge-case inputs (e.g., strings with trailing whitespace or non-numeric suffixes like "5abc" which parseInt parses as 5 but string comparison would behave differently).
Affected file: src/helpers/repeat.ts, line 12
// Before (bug):
for (let i = 0; i < rawNum; i++) {
// After (fix):
for (let i = 0; i < num; i++) {
In
src/helpers/repeat.ts, therepeathelper parses the user-provided count argument usingNumber.parseInt(rawNum)and stores the result innum. However, the subsequentforloop incorrectly uses the originalrawNum(a string) in the comparisoni < rawNuminstead of the parsed integernum.This works accidentally due to JavaScript's implicit type coercion in the
<operator (string is coerced to number), but it is semantically incorrect and could lead to unexpected behavior with edge-case inputs (e.g., strings with trailing whitespace or non-numeric suffixes like"5abc"whichparseIntparses as5but string comparison would behave differently).Affected file:
src/helpers/repeat.ts, line 12