File tree 6 files changed +26
-32
lines changed
6 files changed +26
-32
lines changed Original file line number Diff line number Diff line change 1
1
.DS_Store
2
2
* .log
3
- .nyc_output /
4
3
coverage /
5
4
node_modules /
6
5
yarn.lock
Original file line number Diff line number Diff line change 1
1
coverage /
2
- * .json
3
2
* .md
Original file line number Diff line number Diff line change 1
- module . exports = toString
2
-
3
- function toString ( node ) {
1
+ export function toString ( node ) {
4
2
// A root or an element
5
- if ( 'children' in node ) {
6
- return all ( node )
7
- }
8
-
3
+ if ( 'children' in node ) return all ( node )
9
4
return 'value' in node ? node . value : ''
10
5
}
11
6
12
7
function one ( node ) {
13
- if ( node . type === 'text' ) {
14
- return node . value
15
- }
16
-
8
+ if ( node . type === 'text' ) return node . value
17
9
// Ignore things like comments, instruction, cdata.
18
10
return node . children ? all ( node ) : ''
19
11
}
Original file line number Diff line number Diff line change 24
24
"contributors" : [
25
25
" Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
26
26
],
27
+ "sideEffects" : false ,
28
+ "type" : " module" ,
29
+ "main" : " index.js" ,
27
30
"files" : [
28
31
" index.js"
29
32
],
30
33
"devDependencies" : {
31
- "nyc " : " ^15 .0.0" ,
34
+ "c8 " : " ^7 .0.0" ,
32
35
"prettier" : " ^2.0.0" ,
33
36
"remark-cli" : " ^9.0.0" ,
34
37
"remark-preset-wooorm" : " ^8.0.0" ,
35
38
"tape" : " ^5.0.0" ,
36
- "unist-builder" : " ^2 .0.0" ,
37
- "xo" : " ^0.38 .0"
39
+ "unist-builder" : " ^3 .0.0" ,
40
+ "xo" : " ^0.39 .0"
38
41
},
39
42
"scripts" : {
40
43
"format" : " remark . -qfo && prettier . --write --loglevel warn && xo --fix" ,
41
- "test-api" : " node test" ,
42
- "test-coverage" : " nyc --reporter lcov tape test.js" ,
44
+ "test-api" : " node test.js " ,
45
+ "test-coverage" : " c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 -- reporter lcov node test.js" ,
43
46
"test" : " npm run format && npm run test-coverage"
44
47
},
45
- "nyc" : {
46
- "check-coverage" : true ,
47
- "lines" : 100 ,
48
- "functions" : 100 ,
49
- "branches" : 100
50
- },
51
48
"prettier" : {
52
49
"tabWidth" : 2 ,
53
50
"useTabs" : false ,
58
55
},
59
56
"xo" : {
60
57
"prettier" : true ,
61
- "esnext" : false
58
+ "rules" : {
59
+ "no-var" : " off" ,
60
+ "prefer-arrow-callback" : " off"
61
+ }
62
62
},
63
63
"remarkConfig" : {
64
64
"plugins" : [
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ The resulting text is returned.
15
15
16
16
## Install
17
17
18
+ This package is [ ESM only] ( https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ) :
19
+ Node 12+ is needed to use it and it must be ` import ` ed instead of ` require ` d.
20
+
18
21
[ npm] [ ] :
19
22
20
23
``` sh
@@ -24,8 +27,8 @@ npm install xast-util-to-string
24
27
## Use
25
28
26
29
``` js
27
- var x = require ( ' xastscript' )
28
- var toString = require ( ' xast-util-to-string' )
30
+ import { x } from ' xastscript'
31
+ import { toString } from ' xast-util-to-string'
29
32
30
33
var tree = x (
31
34
' ncx' ,
@@ -50,6 +53,9 @@ A Christmas CarolCharles Dickens
50
53
51
54
## API
52
55
56
+ This package exports the following identifiers: ` toString ` .
57
+ There is no default export.
58
+
53
59
### ` toString(node) `
54
60
55
61
Utility to get the plain text value of a [ * node* ] [ node ] .
Original file line number Diff line number Diff line change 1
- 'use strict'
2
-
3
- var test = require ( 'tape' )
4
- var u = require ( 'unist-builder' )
5
- var toString = require ( '.' )
1
+ import test from 'tape'
2
+ import { u } from 'unist-builder'
3
+ import { toString } from './index.js'
6
4
7
5
test ( 'xast-util-to-string' , function ( t ) {
8
6
t . deepEqual (
You can’t perform that action at this time.
0 commit comments