mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
split utils
This commit is contained in:
parent
8c558e6b34
commit
120bf4a7eb
12 changed files with 858 additions and 834 deletions
13
utils/arrayUtils.js
Normal file
13
utils/arrayUtils.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
"use strict";
|
||||
// FMG utils related to arrays
|
||||
|
||||
// return the last element of array
|
||||
function last(array) {
|
||||
return array[array.length - 1];
|
||||
}
|
||||
|
||||
// return array of values common for both array a and array b
|
||||
function common(a, b) {
|
||||
const setB = new Set(b);
|
||||
return [...new Set(a)].filter(a => setB.has(a));
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue