Merge pull request #30995 from pluma/json_ml

Add json_ml
This commit is contained in:
Andrew Casey
2018-12-06 12:44:12 -08:00
committed by GitHub
4 changed files with 52 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
// Type definitions for json_ml 0.0
// Project: https://github.com/59naga/json-ml
// Definitions by: Alan Plum <https://github.com/pluma>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
/// <reference types="cheerio" />
export type Node = string | [string, ...any[]];
export function parse(xml: string, trim?: boolean): Node[];
export function stringify(
object: Node[],
replacer?: ((node: Cheerio) => any) | null,
indent?: number
): string;
+20
View File
@@ -0,0 +1,20 @@
/// <reference types="node" />
import { Node, parse, stringify } from "json_ml";
const nodes: Node[] = parse(
'<ul><li style="color:red">First Item</li><li title="Some hover text." style="color:green">Second Item</li><li><span class="code-example-third">Third</span>Item</li></ul>'
);
stringify(nodes, el => (el.is("li") ? null : el), 2);
stringify(
[
[
"ul",
["li", { style: "color: red" }],
["li", { title: "Some hover text", style: "color: green" }],
["li", ["span", { class: "code-example-third" }]]
]
],
null,
2
);
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "json_ml-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }