Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7480317
utils.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
utils.js
View Options
/**
* @param {Function} handler A deterministic asynchronous function taking a string and returning Any
* @return {Function} Memoized version (returns the original promise on subsequent calls)
*/
mw
.
editcheck
.
memoize
=
function
(
handler
)
{
const
memory
=
new
Map
();
return
(
arg
,
bypass
)
=>
{
if
(
typeof
arg
!==
'string'
)
{
throw
new
Error
(
'Argument must be a string'
);
}
if
(
bypass
||
!
memory
.
has
(
arg
)
)
{
memory
.
set
(
arg
,
handler
(
arg
)
);
}
return
memory
.
get
(
arg
);
};
};
mw
.
editcheck
.
fetchTimeout
=
function
(
resource
,
options
=
{}
)
{
// eslint-disable-next-line compat/compat
const
abortController
=
window
.
AbortController
?
new
AbortController
()
:
{
signal
:
undefined
,
abort
:
()
=>
{}
};
const
timeoutID
=
setTimeout
(
()
=>
abortController
.
abort
(),
options
.
timeout
||
6000
);
options
.
signal
=
abortController
.
signal
;
return
fetch
(
resource
,
options
).
then
(
(
response
)
=>
{
clearTimeout
(
timeoutID
);
return
response
;
}
).
catch
(
(
error
)
=>
{
clearTimeout
(
timeoutID
);
// If we want to specifically handle the abort case, check for an AbortError here
throw
error
;
}
);
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 23, 12:09 (4 d, 21 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
50/e8/5d2ca5f0a223f1ba0aca1d5c87ac
Default Alt Text
utils.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment