diff --git a/app/generators/uuid/page.tsx b/app/generators/uuid/page.tsx index ccdfd99..0a05719 100644 --- a/app/generators/uuid/page.tsx +++ b/app/generators/uuid/page.tsx @@ -1,7 +1,6 @@ "use client"; import { useCallback, useState } from "react"; -import { range } from "fp-ts/NonEmptyArray"; import { toolGroups } from "@/config/tools"; import { uuid } from "@/lib/uuid"; @@ -58,7 +57,7 @@ export default function Page() { }, []); const onGenerateClick = () => { - const newUuids = range(1, generates).map(_ => uuid(uuidVersion, hyphens, uppercase)); + const newUuids = Array.from({ length: generates }, () => uuid(uuidVersion, hyphens, uppercase)); setUuids([...uuids, ...newUuids]); }; diff --git a/lib/base.ts b/lib/base.ts index 2e13d55..d9a3c7b 100644 --- a/lib/base.ts +++ b/lib/base.ts @@ -1,5 +1,3 @@ -import { chunksOf, intersperse } from "fp-ts/Array"; - const match = (regex: RegExp) => (x: string) => regex.test(x); export const isDecimal = match(/^[0-9]*$/); @@ -8,10 +6,16 @@ export const isOctal = match(/^[0-7]*$/); export const isBinary = match(/^[0-1]*$/); const formatNumber = (digits: number, sep: string) => (s: string) => { - const a = [...s].reverse(); - const b = chunksOf(digits)(a); - const c = intersperse([sep])(b); - return c.flat().reverse().join(""); + const head = ((s.length - 1) % digits) + 1; + const buf = []; + + buf.push(s.substring(0, head)); + + for (let i = head; i < s.length; i += digits) { + buf.push(sep, s.substring(i, i + digits)); + } + + return buf.join(""); }; export const formatDecimal = formatNumber(3, ","); diff --git a/package.json b/package.json index 125d760..9cfeabf 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,6 @@ "clsx": "^1.2.1", "cmdk": "^0.2.0", "create-hash": "^1.2.0", - "fp-ts": "^2.16.0", "fuse.js": "^6.6.2", "html-escaper": "^3.0.3", "js-yaml": "^4.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5050abc..796c13c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -34,9 +34,6 @@ dependencies: create-hash: specifier: ^1.2.0 version: 1.2.0 - fp-ts: - specifier: ^2.16.0 - version: 2.16.0 fuse.js: specifier: ^6.6.2 version: 6.6.2 @@ -3083,10 +3080,6 @@ packages: is-callable: 1.2.7 dev: true - /fp-ts@2.16.0: - resolution: {integrity: sha512-bLq+KgbiXdTEoT1zcARrWEpa5z6A/8b7PcDW7Gef3NSisQ+VS7ll2Xbf1E+xsgik0rWub/8u0qP/iTTjj+PhxQ==} - dev: false - /fraction.js@4.2.0: resolution: {integrity: sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA==} dev: true