File tree Expand file tree Collapse file tree 6 files changed +26
-32
lines changed Expand file tree Collapse file tree 6 files changed +26
-32
lines changed Original file line number Diff line number Diff line change 11.DS_Store
22* .log
3- .nyc_output /
43coverage /
54node_modules /
65yarn.lock
Original file line number Diff line number Diff line change 11coverage /
2- * .json
32* .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 ) {
42 // A root or an element
5- if ( 'children' in node ) {
6- return all ( node )
7- }
8-
3+ if ( 'children' in node ) return all ( node )
94 return 'value' in node ? node . value : ''
105}
116
127function one ( node ) {
13- if ( node . type === 'text' ) {
14- return node . value
15- }
16-
8+ if ( node . type === 'text' ) return node . value
179 // Ignore things like comments, instruction, cdata.
1810 return node . children ? all ( node ) : ''
1911}
Original file line number Diff line number Diff line change 2424 "contributors" : [
2525 " Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
2626 ],
27+ "sideEffects" : false ,
28+ "type" : " module" ,
29+ "main" : " index.js" ,
2730 "files" : [
2831 " index.js"
2932 ],
3033 "devDependencies" : {
31- "nyc " : " ^15 .0.0" ,
34+ "c8 " : " ^7 .0.0" ,
3235 "prettier" : " ^2.0.0" ,
3336 "remark-cli" : " ^9.0.0" ,
3437 "remark-preset-wooorm" : " ^8.0.0" ,
3538 "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"
3841 },
3942 "scripts" : {
4043 "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" ,
4346 "test" : " npm run format && npm run test-coverage"
4447 },
45- "nyc" : {
46- "check-coverage" : true ,
47- "lines" : 100 ,
48- "functions" : 100 ,
49- "branches" : 100
50- },
5148 "prettier" : {
5249 "tabWidth" : 2 ,
5350 "useTabs" : false ,
5855 },
5956 "xo" : {
6057 "prettier" : true ,
61- "esnext" : false
58+ "rules" : {
59+ "no-var" : " off" ,
60+ "prefer-arrow-callback" : " off"
61+ }
6262 },
6363 "remarkConfig" : {
6464 "plugins" : [
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ The resulting text is returned.
1515
1616## Install
1717
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+
1821[ npm] [ ] :
1922
2023``` sh
@@ -24,8 +27,8 @@ npm install xast-util-to-string
2427## Use
2528
2629``` 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'
2932
3033var tree = x (
3134 ' ncx' ,
@@ -50,6 +53,9 @@ A Christmas CarolCharles Dickens
5053
5154## API
5255
56+ This package exports the following identifiers: ` toString ` .
57+ There is no default export.
58+
5359### ` toString(node) `
5460
5561Utility 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'
64
75test ( 'xast-util-to-string' , function ( t ) {
86 t . deepEqual (
You can’t perform that action at this time.
0 commit comments