Skip to content

Commit 2e486fe

Browse files
committed
src/core/util/event_id.ts
1 parent aba10c0 commit 2e486fe

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

packages-exp/auth-exp/src/core/util/event_id.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18-
const MAX_RANDOM_DIGITS = 15;
19-
2018
export function _generateEventId(prefix = '', digits = 10): string {
21-
// This array breaks down digits into a list of numbers, maxed at 15, that
22-
// sums to digits. For example, 10 becomes [10] and 16 becomes [15, 1].
23-
const digitBreakdown = Array(Math.floor(digits / MAX_RANDOM_DIGITS)).fill(
24-
MAX_RANDOM_DIGITS
25-
);
26-
if (digits % MAX_RANDOM_DIGITS) {
27-
digitBreakdown.push(digits % MAX_RANDOM_DIGITS);
19+
let random = '';
20+
for (let i = 0; i < digits; i++) {
21+
random += Math.floor(Math.random() * 10);
2822
}
29-
30-
const random = digitBreakdown
31-
.map(digits =>
32-
Math.floor(Math.random() * Math.pow(10, digits))
33-
.toString()
34-
.padStart(digits, '0')
35-
)
36-
.join('');
3723
return prefix + random;
3824
}

0 commit comments

Comments
 (0)