From 01e46d99cd9c14e826fa198171d7e17d7896a721 Mon Sep 17 00:00:00 2001 From: yonada Date: Mon, 11 Mar 2024 14:50:25 +0000 Subject: [PATCH] chore: remove some unused files (#2398) --- .changeset/dry-flowers-shave.md | 6 ++++++ packages/common/src/utils/curry.ts | 12 ------------ packages/common/src/utils/index.ts | 1 - packages/dev-tools/src/exhaustiveCheck.ts | 3 --- .../src/recs/serializeWithoutIndexedValues.ts | 13 ------------- packages/react/src/index.ts | 1 - packages/react/src/useDeprecatedComputedValue.ts | 14 -------------- 7 files changed, 6 insertions(+), 44 deletions(-) create mode 100644 .changeset/dry-flowers-shave.md delete mode 100644 packages/common/src/utils/curry.ts delete mode 100644 packages/dev-tools/src/exhaustiveCheck.ts delete mode 100644 packages/dev-tools/src/recs/serializeWithoutIndexedValues.ts delete mode 100644 packages/react/src/useDeprecatedComputedValue.ts diff --git a/.changeset/dry-flowers-shave.md b/.changeset/dry-flowers-shave.md new file mode 100644 index 0000000000..3c767b80fc --- /dev/null +++ b/.changeset/dry-flowers-shave.md @@ -0,0 +1,6 @@ +--- +"@latticexyz/common": patch +"@latticexyz/react": patch +--- + +Removed some unused files, namely `curry` in `@latticexyz/common` and `useDeprecatedComputedValue` from `@latticexyz/react`. diff --git a/packages/common/src/utils/curry.ts b/packages/common/src/utils/curry.ts deleted file mode 100644 index daaf4a5785..0000000000 --- a/packages/common/src/utils/curry.ts +++ /dev/null @@ -1,12 +0,0 @@ -export function curry any, P extends any[]>( - func: F, - ...partialParams: P -): CurryParams { - return ((...args: any[]) => func(...partialParams, ...args)) as CurryParams; -} - -type CurryParams any, PartialParams extends any[]> = F extends ( - ...params: [...PartialParams, ...infer RemainingParams] -) => infer Result - ? (...params: RemainingParams) => Result - : never; diff --git a/packages/common/src/utils/index.ts b/packages/common/src/utils/index.ts index 37d4ce5838..2e4b585754 100644 --- a/packages/common/src/utils/index.ts +++ b/packages/common/src/utils/index.ts @@ -3,7 +3,6 @@ export * from "./bigIntMax"; export * from "./bigIntMin"; export * from "./bigIntSort"; export * from "./chunk"; -export * from "./curry"; export * from "./groupBy"; export * from "./identity"; export * from "./includes"; diff --git a/packages/dev-tools/src/exhaustiveCheck.ts b/packages/dev-tools/src/exhaustiveCheck.ts deleted file mode 100644 index 9fb6a51b2a..0000000000 --- a/packages/dev-tools/src/exhaustiveCheck.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function exhaustiveCheck(value: never, message?: string): never { - throw new Error(message ?? `Unexpected value: ${value}`); -} diff --git a/packages/dev-tools/src/recs/serializeWithoutIndexedValues.ts b/packages/dev-tools/src/recs/serializeWithoutIndexedValues.ts deleted file mode 100644 index 57d0b5847d..0000000000 --- a/packages/dev-tools/src/recs/serializeWithoutIndexedValues.ts +++ /dev/null @@ -1,13 +0,0 @@ -export function serializeWithoutIndexedValues(obj: any) { - return JSON.stringify(obj, (key, value) => { - // strip indexed values - if (/^\d+$/.test(key)) { - return; - } - // serialize bigints as strings - if (typeof value === "bigint") { - return value.toString(); - } - return value; - }); -} diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts index ebc3b4f4fb..698b1f810a 100644 --- a/packages/react/src/index.ts +++ b/packages/react/src/index.ts @@ -1,5 +1,4 @@ export * from "./useComponentValue"; -export * from "./useDeprecatedComputedValue"; export * from "./useEntityQuery"; export * from "./useObservableValue"; export * from "./usePromise"; diff --git a/packages/react/src/useDeprecatedComputedValue.ts b/packages/react/src/useDeprecatedComputedValue.ts deleted file mode 100644 index ec6f5dbf47..0000000000 --- a/packages/react/src/useDeprecatedComputedValue.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { IComputedValue } from "mobx"; -import { useEffect, useState } from "react"; - -/** @deprecated See https://github.com/latticexyz/mud/issues/339 */ -export const useDeprecatedComputedValue = (computedValue: IComputedValue & { observe_: any }) => { - const [value, setValue] = useState(computedValue.get()); - - useEffect(() => { - const unsubscribe = computedValue.observe_(() => setValue(computedValue.get())); - return () => unsubscribe(); - }, [computedValue]); - - return value; -};