Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
spnati
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SPNATI Utilities Bot
spnati
Commits
1dd48acf
Commit
1dd48acf
authored
5 years ago
by
FarawayVision
Browse files
Options
Downloads
Patches
Plain Diff
Monika: polyfill `String.prototype.repeat` if necessary
Closes #25 Resolves Sentry issue SPNATI-4J
parent
38240a80
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opponents/monika/js/monika.js
+41
-0
41 additions, 0 deletions
opponents/monika/js/monika.js
with
41 additions
and
0 deletions
opponents/monika/js/monika.js
+
41
−
0
View file @
1dd48acf
if
(
!
monika
)
var
monika
=
(
function
(
root
)
{
/* Polyfill String.prototype.repeat */
if
(
!
String
.
prototype
.
repeat
)
{
String
.
prototype
.
repeat
=
function
(
count
)
{
'
use strict
'
;
if
(
this
==
null
)
throw
new
TypeError
(
'
can
\'
t convert
'
+
this
+
'
to object
'
);
var
str
=
''
+
this
;
// To convert string to integer.
count
=
+
count
;
// Check NaN
if
(
count
!=
count
)
count
=
0
;
if
(
count
<
0
)
throw
new
RangeError
(
'
repeat count must be non-negative
'
);
if
(
count
==
Infinity
)
throw
new
RangeError
(
'
repeat count must be less than infinity
'
);
count
=
Math
.
floor
(
count
);
if
(
str
.
length
==
0
||
count
==
0
)
return
''
;
// Ensuring count is a 31-bit integer allows us to heavily optimize the
// main part. But anyway, most current (August 2014) browsers can't handle
// strings 1 << 28 chars or longer, so:
if
(
str
.
length
*
count
>=
1
<<
28
)
throw
new
RangeError
(
'
repeat count must not overflow maximum string size
'
);
var
maxCount
=
str
.
length
*
count
;
count
=
Math
.
floor
(
Math
.
log
(
count
)
/
Math
.
log
(
2
));
while
(
count
)
{
str
+=
str
;
count
--
;
}
str
+=
str
.
substring
(
0
,
maxCount
-
str
.
length
);
return
str
;
}
}
var
exports
=
{};
if
(
root
.
SENTRY_INITIALIZED
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment