mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 20:11:24 +01:00
hasCoadjacentSameStateCells checks
This commit is contained in:
parent
6fc9b75e00
commit
fd450a20c1
1 changed files with 23 additions and 23 deletions
|
|
@ -68,7 +68,7 @@ function deepCopy(obj) {
|
||||||
const id = x => x;
|
const id = x => x;
|
||||||
const dcTArray = a => a.map(id);
|
const dcTArray = a => a.map(id);
|
||||||
const dcObject = x => Object.fromEntries(Object.entries(x).map(([k, d]) => [k, dcAny(d)]));
|
const dcObject = x => Object.fromEntries(Object.entries(x).map(([k, d]) => [k, dcAny(d)]));
|
||||||
const dcAny = x => x instanceof Object ? (cf.get(x.constructor)||id)(x) : x;
|
const dcAny = x => (x instanceof Object ? (cf.get(x.constructor) || id)(x) : x);
|
||||||
// don't map keys, probably this is what we would expect
|
// don't map keys, probably this is what we would expect
|
||||||
const dcMapCore = m => [...m.entries()].map(([k, v]) => [k, dcAny(v)]);
|
const dcMapCore = m => [...m.entries()].map(([k, v]) => [k, dcAny(v)]);
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ function deepCopy(obj) {
|
||||||
[Array, a => a.map(dcAny)],
|
[Array, a => a.map(dcAny)],
|
||||||
[Set, s => [...s.values()].map(dcAny)],
|
[Set, s => [...s.values()].map(dcAny)],
|
||||||
[Date, d => new Date(d.getTime())],
|
[Date, d => new Date(d.getTime())],
|
||||||
[Object, dcObject],
|
[Object, dcObject]
|
||||||
// other types will be referenced
|
// other types will be referenced
|
||||||
// ... extend here to implement their custom deep copy
|
// ... extend here to implement their custom deep copy
|
||||||
]);
|
]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue