13
app/utilities.js
Executable file
13
app/utilities.js
Executable file
@@ -0,0 +1,13 @@
|
||||
const allAvatars = (ctx => {
|
||||
let keys = ctx.keys();
|
||||
return keys.map(ctx);
|
||||
})(require.context('./images/avatars', true, /.*/));
|
||||
|
||||
export function randomArray(arr) {
|
||||
const index = Math.round(Math.random() * (arr.length - 1));
|
||||
return arr[index];
|
||||
}
|
||||
|
||||
export function randomAvatar() {
|
||||
return randomArray(allAvatars);
|
||||
}
|
Reference in New Issue
Block a user