artdaq_node_server
v1_00_09
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Variables
Pages
src
node_modules
xml2js
node_modules
xmlbuilder
node_modules
lodash
_baseRepeat.js
1
2
var MAX_SAFE_INTEGER = 9007199254740991;
3
4
/* Built-in method references for those with the same name as other `lodash` methods. */
5
var nativeFloor = Math.floor;
6
15
function
baseRepeat(
string
, n) {
16
var result =
''
;
17
if
(!
string
|| n < 1 || n > MAX_SAFE_INTEGER) {
18
return
result;
19
}
20
// Leverage the exponentiation by squaring algorithm for a faster repeat.
21
// See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details.
22
do
{
23
if
(n % 2) {
24
result += string;
25
}
26
n = nativeFloor(n / 2);
27
if
(n) {
28
string
+= string;
29
}
30
}
while
(n);
31
32
return
result;
33
}
34
35
module.exports = baseRepeat;
Generated on Tue Aug 8 2017 08:55:43 for artdaq_node_server by
1.8.5