Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F969892
BufferedPool.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
655 B
Referenced Files
None
Subscribers
None
BufferedPool.js
View Options
function
bufferedPool
(
getter
,
picker
)
{
let
pool
=
[];
let
promiseOfPool
=
getter
().
then
(
results
=>
{
pool
=
results
;
return
pool
;
});
return
function
()
{
return
promiseOfPool
.
then
(
function
()
{
if
(
pool
.
length
===
0
)
{
throw
new
Error
(
"Empty array"
);
}
return
picker
(
pool
);
});
};
}
export
function
popRandomElement
(
array
)
{
let
index
=
Math
.
floor
(
Math
.
random
()
*
array
.
length
);
let
lastIndex
=
array
.
length
-
1
;
[
array
[
index
],
array
[
lastIndex
]]
=
[
array
[
lastIndex
],
array
[
index
]];
return
array
.
pop
();
}
export
default
bufferedPool
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 02:20 (22 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
548089
Default Alt Text
BufferedPool.js (655 B)
Attached To
Mode
rRS random-slides
Attached
Detach File
Event Timeline
Log In to Comment