1- 'use strict'
2-
3- module . exports = toMdast
4-
5- var has = require ( 'hast-util-has-property' )
6- var minify = require ( 'rehype-minify-whitespace' )
7- var convert = require ( 'unist-util-is/convert' )
8- var visit = require ( 'unist-util-visit' )
9- var xtend = require ( 'xtend' )
10- var one = require ( './lib/one' )
11- var handlers = require ( './lib/handlers' )
12- var own = require ( './lib/util/own' )
1+ import { hasProperty } from 'hast-util-has-property'
2+ import minify from 'rehype-minify-whitespace'
3+ import { convert } from 'unist-util-is'
4+ import { visit } from 'unist-util-visit'
5+ import { one } from './lib/one.js'
6+ import { handlers } from './lib/handlers/index.js'
7+ import { own } from './lib/util/own.js'
138
149var block = convert ( [ 'heading' , 'paragraph' , 'root' ] )
1510
16- function toMdast ( tree , options ) {
11+ export function toMdast ( tree , options ) {
1712 var settings = options || { }
1813 var byId = { }
1914 var mdast
@@ -24,7 +19,9 @@ function toMdast(tree, options) {
2419 h . wrapText = true
2520 h . qNesting = 0
2621
27- h . handlers = settings . handlers ? xtend ( handlers , settings . handlers ) : handlers
22+ h . handlers = settings . handlers
23+ ? { ...handlers , ...settings . handlers }
24+ : handlers
2825 h . augment = augment
2926
3027 h . document = settings . document
@@ -54,7 +51,7 @@ function toMdast(tree, options) {
5451 props = { }
5552 }
5653
57- result = xtend ( { type : type } , props )
54+ result = { type, ... props }
5855
5956 if ( typeof children === 'string' ) {
6057 result . value = children
@@ -76,7 +73,7 @@ function toMdast(tree, options) {
7673 }
7774
7875 function onelement ( node ) {
79- var id = has ( node , 'id' ) && String ( node . properties . id ) . toUpperCase ( )
76+ var id = hasProperty ( node , 'id' ) && String ( node . properties . id ) . toUpperCase ( )
8077
8178 if ( id && ! own . call ( byId , id ) ) {
8279 byId [ id ] = node
0 commit comments