Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions constants/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,3 +530,8 @@ pub contract Example {
}
}
`;
export const square = `[
[1, 2, 3],
[2, 3, 1],
[3, 1, 2],
]`;
23 changes: 23 additions & 0 deletions pages/square-to-curly.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import ConversionPanel from "@components/ConversionPanel";
import { useCallback } from "react";
import * as React from "react";

export default function SquareToCurly() {
const transformer = useCallback(async ({ value }) => {
if (typeof value === "string") {
return value.replace(/\[/g, "{").replace(/\]/g, "}");
}
return "";
}, []);

return (
<ConversionPanel
transformer={transformer}
editorTitle="Square Brackets"
editorDefaultValue="square"
editorLanguage="plaintext"
resultTitle="Curly Braces"
resultLanguage={"plaintext"}
/>
);
}
6 changes: 5 additions & 1 deletion utils/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export const categorizedRoutes = [
label: "to Typescript",
path: "/js-object-to-typescript",
desc: "An online REPL for converting JS Object to Typescript."
},
}
]
},
{
Expand Down Expand Up @@ -393,6 +393,10 @@ export const categorizedRoutes = [
{
label: "Cadence to Go",
path: "/cadence-to-go"
},
{
label: "[] to {}",
path: "/square-to-curly"
}
]
}
Expand Down