From f4b77e852deff0e1092781ab286eaee5bec3a571 Mon Sep 17 00:00:00 2001 From: jakub791 Date: Thu, 4 May 2023 12:48:20 +0200 Subject: [PATCH] use Array.isArray instead of isArray --- src/features/achievements/achievement.tsx | 3 +-- src/features/action.tsx | 3 +-- src/features/challenges/challenge.tsx | 3 +-- src/features/repeatable.tsx | 3 +-- src/features/upgrades/upgrade.ts | 3 +-- src/game/persistence.ts | 3 +-- src/game/requirements.tsx | 11 +++++------ 7 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/features/achievements/achievement.tsx b/src/features/achievements/achievement.tsx index 5b9aa05..cce0821 100644 --- a/src/features/achievements/achievement.tsx +++ b/src/features/achievements/achievement.tsx @@ -1,5 +1,4 @@ import { computed } from "vue"; -import { isArray } from "@vue/shared"; import Select from "components/fields/Select.vue"; import AchievementComponent from "features/achievements/Achievement.vue"; import { GenericDecorator } from "features/decorators/common"; @@ -272,7 +271,7 @@ export function createAchievement( const requirements = [ createVisibilityRequirement(genericAchievement), createBooleanRequirement(() => !genericAchievement.earned.value), - ...(isArray(achievement.requirements) + ...(Array.isArray(achievement.requirements) ? achievement.requirements : [achievement.requirements]) ]; diff --git a/src/features/action.tsx b/src/features/action.tsx index 7d392bb..e85eb7b 100644 --- a/src/features/action.tsx +++ b/src/features/action.tsx @@ -1,4 +1,3 @@ -import { isArray } from "@vue/shared"; import ClickableComponent from "features/clickables/Clickable.vue"; import { Component, @@ -157,7 +156,7 @@ export function createAction( } ]; const originalStyle = unref(style); - if (isArray(originalStyle)) { + if (Array.isArray(originalStyle)) { currStyle.push(...originalStyle); } else if (originalStyle != null) { currStyle.push(originalStyle); diff --git a/src/features/challenges/challenge.tsx b/src/features/challenges/challenge.tsx index d9fc04d..a741d95 100644 --- a/src/features/challenges/challenge.tsx +++ b/src/features/challenges/challenge.tsx @@ -1,4 +1,3 @@ -import { isArray } from "@vue/shared"; import Toggle from "components/fields/Toggle.vue"; import ChallengeComponent from "features/challenges/Challenge.vue"; import { GenericDecorator } from "features/decorators/common"; @@ -355,7 +354,7 @@ export function createActiveChallenge( export function isAnyChallengeActive( challenges: GenericChallenge[] | Ref ): Ref { - if (isArray(challenges)) { + if (Array.isArray(challenges)) { challenges = createActiveChallenge(challenges); } return computed(() => (challenges as Ref).value != null); diff --git a/src/features/repeatable.tsx b/src/features/repeatable.tsx index eb34af5..80dc37c 100644 --- a/src/features/repeatable.tsx +++ b/src/features/repeatable.tsx @@ -1,4 +1,3 @@ -import { isArray } from "@vue/shared"; import ClickableComponent from "features/clickables/Clickable.vue"; import type { CoercableComponent, @@ -165,7 +164,7 @@ export function createRepeatable( visibility: Visibility.None } as const; const visibilityRequirement = createVisibilityRequirement(repeatable as GenericRepeatable); - if (isArray(repeatable.requirements)) { + if (Array.isArray(repeatable.requirements)) { repeatable.requirements.unshift(visibilityRequirement); repeatable.requirements.push(limitRequirement); } else { diff --git a/src/features/upgrades/upgrade.ts b/src/features/upgrades/upgrade.ts index 9ff9b28..a3075e7 100644 --- a/src/features/upgrades/upgrade.ts +++ b/src/features/upgrades/upgrade.ts @@ -1,4 +1,3 @@ -import { isArray } from "@vue/shared"; import { GenericDecorator } from "features/decorators/common"; import type { CoercableComponent, @@ -151,7 +150,7 @@ export function createUpgrade( }; const visibilityRequirement = createVisibilityRequirement(upgrade as GenericUpgrade); - if (isArray(upgrade.requirements)) { + if (Array.isArray(upgrade.requirements)) { upgrade.requirements.unshift(visibilityRequirement); } else { upgrade.requirements = [visibilityRequirement, upgrade.requirements]; diff --git a/src/game/persistence.ts b/src/game/persistence.ts index 712f989..57c5fe1 100644 --- a/src/game/persistence.ts +++ b/src/game/persistence.ts @@ -1,4 +1,3 @@ -import { isArray } from "@vue/shared"; import { globalBus } from "game/events"; import type { GenericLayer } from "game/layers"; import { addingLayers, persistentRefs } from "game/layers"; @@ -342,7 +341,7 @@ globalBus.on("addLayer", (layer: GenericLayer, saveData: Record // Show warning for persistent values inside arrays // TODO handle arrays better if (foundPersistentInChild) { - if (isArray(value) && !isArray(obj)) { + if (Array.isArray(value) && !Array.isArray(obj)) { console.warn( "Found array that contains persistent values when adding layer. Keep in mind changing the order of elements in the array will mess with existing player saves.", ProxyState in obj diff --git a/src/game/requirements.tsx b/src/game/requirements.tsx index 0b00192..d393bfb 100644 --- a/src/game/requirements.tsx +++ b/src/game/requirements.tsx @@ -1,4 +1,3 @@ -import { isArray } from "@vue/shared"; import { CoercableComponent, isVisible, @@ -241,7 +240,7 @@ export function createBooleanRequirement( * @param requirements The 1+ requirements to check */ export function requirementsMet(requirements: Requirements): boolean { - if (isArray(requirements)) { + if (Array.isArray(requirements)) { return requirements.every(requirementsMet); } const reqsMet = unref(requirements.requirementMet); @@ -253,7 +252,7 @@ export function requirementsMet(requirements: Requirements): boolean { * @param requirements The 1+ requirements to check */ export function maxRequirementsMet(requirements: Requirements): DecimalSource { - if (isArray(requirements)) { + if (Array.isArray(requirements)) { return requirements.map(maxRequirementsMet).reduce(Decimal.min); } const reqsMet = unref(requirements.requirementMet); @@ -271,13 +270,13 @@ export function maxRequirementsMet(requirements: Requirements): DecimalSource { * @param amount The amount of levels earned to be displayed */ export function displayRequirements(requirements: Requirements, amount: DecimalSource = 1) { - if (isArray(requirements)) { + if (Array.isArray(requirements)) { requirements = requirements.filter(r => isVisible(r.visibility)); if (requirements.length === 1) { requirements = requirements[0]; } } - if (isArray(requirements)) { + if (Array.isArray(requirements)) { requirements = requirements.filter(r => "partialDisplay" in r); const withCosts = requirements.filter(r => unref(r.requiresPay)); const withoutCosts = requirements.filter(r => !unref(r.requiresPay)); @@ -315,7 +314,7 @@ export function displayRequirements(requirements: Requirements, amount: DecimalS * @param amount How many levels to pay for */ export function payRequirements(requirements: Requirements, amount: DecimalSource = 1) { - if (isArray(requirements)) { + if (Array.isArray(requirements)) { requirements.filter(r => unref(r.requiresPay)).forEach(r => r.pay?.(amount)); } else if (unref(requirements.requiresPay)) { requirements.pay?.(amount);