File tree 5 files changed +109
-2
lines changed
5 files changed +109
-2
lines changed Original file line number Diff line number Diff line change 23
23
],
24
24
"files" : [
25
25
" lib" ,
26
- " index.js"
26
+ " index.js" ,
27
+ " types/index.d.ts"
27
28
],
29
+ "types" : " types" ,
28
30
"dependencies" : {
31
+ "@types/xast" : " ^1.0.0" ,
29
32
"ccount" : " ^1.0.0" ,
30
33
"stringify-entities" : " ^2.0.0"
31
34
},
32
35
"devDependencies" : {
33
36
"browserify" : " ^16.0.0" ,
37
+ "dtslint" : " ^4.0.0" ,
34
38
"nyc" : " ^15.0.0" ,
35
39
"prettier" : " ^2.0.0" ,
36
40
"remark-cli" : " ^8.0.0" ,
45
49
"format" : " remark . -qfo && prettier . --write && xo --fix" ,
46
50
"test-api" : " node test" ,
47
51
"test-coverage" : " nyc --reporter lcov tape test/index.js" ,
48
- "test" : " npm run format && npm run test-coverage"
52
+ "test-types" : " dtslint types" ,
53
+ "test" : " npm run format && npm run test-coverage && npm run test-types"
49
54
},
50
55
"prettier" : {
51
56
"tabWidth" : 2 ,
Original file line number Diff line number Diff line change
1
+ // TypeScript Version: 3.0
2
+
3
+ import { Node } from 'xast'
4
+
5
+ declare namespace toXml {
6
+ interface Options {
7
+ /**
8
+ * Preferred quote to use.
9
+ *
10
+ * @default '"'
11
+ */
12
+ quote ?: '"' | "'"
13
+
14
+ /**
15
+ * Use the other quote if that results in less bytes.
16
+ *
17
+ * @default false
18
+ */
19
+ quoteSmart ?: boolean
20
+
21
+ /**
22
+ * Close elements without any content with slash (/) on the opening tag
23
+ * instead of an end tag: `<circle />` instead of `<circle></circle>`.
24
+ * See `tightClose` to control whether a space is used before the slash.
25
+ *
26
+ * @default false
27
+ */
28
+ closeEmptyElements ?: boolean
29
+
30
+ /**
31
+ * Do not use an extra space when closing self-closing elements:
32
+ * `<circle/>` instead of `<circle />`.
33
+ *
34
+ * @default false
35
+ */
36
+ tightClose ?: boolean
37
+
38
+ /**
39
+ * Allow `raw` nodes and insert them as raw XML. When falsey, encodes `raw` nodes.
40
+ * Only set this if you completely trust the content!
41
+ *
42
+ * @default false
43
+ */
44
+ allowDangerousXml ?: boolean
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Serialize the given xast tree to xml.
50
+ *
51
+ * @param tree Tree or list of nodes
52
+ * @param options Options
53
+ */
54
+ declare function toXml ( tree : Node | Node [ ] , options ?: toXml . Options ) : string
55
+
56
+ export = toXml
Original file line number Diff line number Diff line change
1
+ import toXml = require( 'xast-util-to-xml' )
2
+ import { Element } from 'xast'
3
+
4
+ const xmlns = 'http://www.sitemaps.org/schemas/sitemap/0.9'
5
+ const element : Element = {
6
+ type : 'element' ,
7
+ name : 'urlset' ,
8
+ attributes : { xmlns} ,
9
+ children : [ ]
10
+ }
11
+
12
+ toXml ( element ) // $ExpectType string
13
+ toXml ( [ element ] ) // $ExpectType string
14
+ toXml ( element , { allowDangerousXml : true } ) // $ExpectType string
15
+ toXml ( element , { quote : "'" } ) // $ExpectType string
16
+ toXml ( element , { quoteSmart : true } ) // $ExpectType string
17
+ toXml ( element , { closeEmptyElements : true } ) // $ExpectType string
18
+ toXml ( element , { closeEmptyElements : true , tightClose : true } ) // $ExpectType string
19
+
20
+ toXml ( ) // $ExpectError
21
+ toXml ( false ) // $ExpectError
22
+ toXml ( element , element ) // $ExpectError
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "module" : " commonjs" ,
4
+ "lib" : [" es2015" ],
5
+ "noImplicitAny" : true ,
6
+ "noImplicitThis" : true ,
7
+ "strictNullChecks" : true ,
8
+ "strictFunctionTypes" : true ,
9
+ "noEmit" : true ,
10
+ "baseUrl" : " ." ,
11
+ "paths" : {
12
+ "xast-util-to-xml" : [" ." ]
13
+ }
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "extends" : " dtslint/dtslint.json" ,
3
+ "rules" : {
4
+ "no-redundant-jsdoc" : false ,
5
+ "no-redundant-jsdoc-2" : true ,
6
+ "semicolon" : false ,
7
+ "whitespace" : false
8
+ }
9
+ }
You can’t perform that action at this time.
0 commit comments