mirror of
https://github.com/ershisan99/DevToysWeb.git
synced 2026-01-07 20:52:07 +00:00
Merge branch 'main' into feature/text/diff
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useState } from "react";
|
||||
import { decode, encode, isValid } from "js-base64";
|
||||
|
||||
import { toolGroups } from "@/config/tools";
|
||||
import { decode, encode } from "@/lib/base64";
|
||||
import { Textarea, TextareaProps } from "@/components/ui/textarea";
|
||||
import * as Button from "@/components/buttons";
|
||||
import { ControlMenu } from "@/components/control-menu";
|
||||
@@ -24,10 +24,10 @@ export default function Page() {
|
||||
}, []);
|
||||
|
||||
const setFormByEncoded = useCallback((text: string) => {
|
||||
const newDecoded = decode(text);
|
||||
const newDecoded = decode(text) ?? "";
|
||||
|
||||
setForm({
|
||||
decoded: isValid(text) && !newDecoded.includes("<22>") ? newDecoded : "",
|
||||
decoded: newDecoded.includes("<22>") ? "" : newDecoded,
|
||||
encoded: text,
|
||||
});
|
||||
}, []);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useState } from "react";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
|
||||
import { toolGroups } from "@/config/tools";
|
||||
import { safeJsonParse } from "@/lib/json";
|
||||
@@ -25,7 +25,7 @@ export default function Page() {
|
||||
const [indentation, setIndentation] = useState(indentations.two);
|
||||
const [input, setInput] = useState('{\n"foo":"bar"\n}');
|
||||
|
||||
const parsed = safeJsonParse(input);
|
||||
const parsed = useMemo(() => safeJsonParse(input), [input]);
|
||||
const output = parsed.map(x => JSON.stringify(x, null, indentation)).unwrapOr("");
|
||||
|
||||
const clearInput = useCallback(() => setInput(""), []);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useState } from "react";
|
||||
import createHash from "create-hash";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import MD5 from "crypto-js/md5";
|
||||
import SHA1 from "crypto-js/sha1";
|
||||
import SHA256 from "crypto-js/sha256";
|
||||
import SHA512 from "crypto-js/sha512";
|
||||
|
||||
import { toolGroups } from "@/config/tools";
|
||||
import { Input } from "@/components/ui/input";
|
||||
@@ -19,10 +22,10 @@ export default function Page() {
|
||||
const [uppercase, setUppercase] = useState(false);
|
||||
const [input, setInput] = useState("Hello there !");
|
||||
|
||||
const newMd5 = createHash("md5").update(input).digest("hex");
|
||||
const newSha1 = createHash("sha1").update(input).digest("hex");
|
||||
const newSha256 = createHash("sha256").update(input).digest("hex");
|
||||
const newSha512 = createHash("sha512").update(input).digest("hex");
|
||||
const newMd5 = useMemo(() => MD5(input).toString(), [input]);
|
||||
const newSha1 = useMemo(() => SHA1(input).toString(), [input]);
|
||||
const newSha256 = useMemo(() => SHA256(input).toString(), [input]);
|
||||
const newSha512 = useMemo(() => SHA512(input).toString(), [input]);
|
||||
|
||||
const md5 = uppercase ? newMd5.toUpperCase() : newMd5;
|
||||
const sha1 = uppercase ? newSha1.toUpperCase() : newSha1;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useState } from "react";
|
||||
import { range } from "fp-ts/NonEmptyArray";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
|
||||
import { toolGroups } from "@/config/tools";
|
||||
import { uuid } from "@/lib/uuid";
|
||||
@@ -39,7 +38,7 @@ export default function Page() {
|
||||
const [uuids, setUuids] = useState<string[]>([]);
|
||||
const ref = useAutoScroll<HTMLTextAreaElement>([uuids]);
|
||||
|
||||
const uuidsString = uuids.join("\n");
|
||||
const uuidsString = useMemo(() => uuids.join("\n"), [uuids]);
|
||||
|
||||
const clearUuids = useCallback(() => setUuids([]), []);
|
||||
|
||||
@@ -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]);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user