MCPcopy
hub / github.com/bigskysoftware/htmx / stringRepeat

Function stringRepeat

test/core/perf.js:16–30  ·  view source on GitHub ↗
(str, num)

Source from the content-addressed store, hash-verified

14 })
15
16 function stringRepeat(str, num) {
17 num = Number(num)
18
19 var result = ''
20 while (true) {
21 if (num & 1) { // (1)
22 result += str
23 }
24 num >>>= 1 // (2)
25 if (num <= 0) break
26 str += str
27 }
28
29 return result
30 }
31
32 it('history implementation should be fast', function() {
33 // create an entry with a large content string (256k) and see how fast we can write and read it

Callers 1

perf.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected