mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 02:01:22 +01:00
refactor(es modules): continue migration
This commit is contained in:
parent
030caec6e8
commit
a929667796
16 changed files with 30 additions and 16 deletions
|
|
@ -8,18 +8,6 @@ export function unique<T>(array: T[]) {
|
|||
return [...new Set(array)];
|
||||
}
|
||||
|
||||
function getTypedArray(maxValue: number) {
|
||||
console.assert(
|
||||
Number.isInteger(maxValue) && maxValue >= 0 && maxValue <= UINT32_MAX,
|
||||
`Array maxValue must be an integer between 0 and ${UINT32_MAX}, got ${maxValue}`
|
||||
);
|
||||
|
||||
if (maxValue <= UINT8_MAX) return Uint8Array;
|
||||
if (maxValue <= UINT16_MAX) return Uint16Array;
|
||||
if (maxValue <= UINT32_MAX) return Uint32Array;
|
||||
return Uint32Array;
|
||||
}
|
||||
|
||||
interface ICreateTypedArray {
|
||||
maxValue: number;
|
||||
length: number;
|
||||
|
|
@ -31,3 +19,15 @@ export function createTypedArray({maxValue, length, from}: ICreateTypedArray) {
|
|||
if (!from) return new typedArray(length);
|
||||
return typedArray.from(from);
|
||||
}
|
||||
|
||||
function getTypedArray(maxValue: number) {
|
||||
console.assert(
|
||||
Number.isInteger(maxValue) && maxValue >= 0 && maxValue <= UINT32_MAX,
|
||||
`Array maxValue must be an integer between 0 and ${UINT32_MAX}, got ${maxValue}`
|
||||
);
|
||||
|
||||
if (maxValue <= UINT8_MAX) return Uint8Array;
|
||||
if (maxValue <= UINT16_MAX) return Uint16Array;
|
||||
if (maxValue <= UINT32_MAX) return Uint32Array;
|
||||
return Uint32Array;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue