mirror of
https://github.com/ritz078/transform.git
synced 2026-11-21 16:43:56 +03:00
add YAML to TOML and TOML to YAML (#301)
* add JSON to TOML * change function name to JsonToToml * add TOML to JSON * add package iarna-toml * feat: add YAML to TOML * feat: add TOML to YAML * chore(yaml-to-toml): change func name
This commit is contained in:
1 parent
a66a6acb69
commit
3ba8b163a3
3 files changed
+51
-1
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import ConversionPanel from "@components/ConversionPanel";
|
||||
import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import yaml from "yaml";
|
||||
import toml from "@iarna/toml";
|
||||
|
||||
export default function TomlToYaml() {
|
||||
const transformer = useCallback(
|
||||
({ value }) => Promise.resolve(yaml.stringify(toml.parse(value))),
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<ConversionPanel
|
||||
transformer={transformer}
|
||||
editorTitle="TOML"
|
||||
editorLanguage="toml"
|
||||
resultTitle="YAML"
|
||||
resultLanguage={"yaml"}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import ConversionPanel from "@components/ConversionPanel";
|
||||
import { useCallback } from "react";
|
||||
import * as React from "react";
|
||||
import yaml from "yaml";
|
||||
import toml from "@iarna/toml";
|
||||
|
||||
export default function YamlToToml() {
|
||||
const transformer = useCallback(async ({ value }) => {
|
||||
return toml.stringify(yaml.parse(value));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<ConversionPanel
|
||||
transformer={transformer}
|
||||
editorTitle="YAML"
|
||||
editorLanguage="yaml"
|
||||
resultTitle="TOML"
|
||||
resultLanguage={"toml"}
|
||||
/>
|
||||
);
|
||||
}
|
||||
+8
-1
@@ -327,13 +327,16 @@ export const categorizedRoutes = [
|
||||
packageName: "xml-js",
|
||||
packageUrl: "https://github.com/nashwaan/xml-js"
|
||||
},
|
||||
|
||||
{
|
||||
label: "YAML to JSON",
|
||||
path: "/yaml-to-json",
|
||||
packageName: "yaml",
|
||||
packageUrl: "https://github.com/tj/js-yaml"
|
||||
},
|
||||
{
|
||||
label: "YAML to TOML",
|
||||
path: "/yaml-to-toml"
|
||||
},
|
||||
{
|
||||
label: "Markdown to HTML",
|
||||
path: "/markdown-to-html",
|
||||
@@ -345,6 +348,10 @@ export const categorizedRoutes = [
|
||||
path: "/toml-to-json",
|
||||
packageUrl: "https://www.npmjs.com/package/@iarna/toml",
|
||||
packageName: "@iarna/toml"
|
||||
},
|
||||
{
|
||||
label: "TOML to YAML",
|
||||
path: "/toml-to-yaml"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user