@@ -3,21 +3,31 @@ import { is } from 'unist-util-is'
33
44const HeadingTag = [ 'h1' , 'h2' , 'h3' ]
55
6- export const isTag = ( t : any , tagName : string | string [ ] ) =>
7- is ( t , { type : 'element' } ) &&
8- [ tagName ] . flat ( ) . includes ( ( t as Element ) . tagName )
9- export const isHeading = ( t : any , tagName ?: string | string [ ] ) : t is Element =>
10- is ( t , { type : 'element' } ) && tagName
6+ export function isTag ( t : any , tagName : string | string [ ] ) {
7+ return (
8+ is ( t , { type : 'element' } ) &&
9+ [ tagName ] . flat ( ) . includes ( ( t as Element ) . tagName )
10+ )
11+ }
12+ export function isHeading ( t : any , tagName ?: string | string [ ] ) : t is Element {
13+ return is ( t , { type : 'element' } ) && tagName
1114 ? [ tagName ] . flat ( ) . includes ( ( t as Element ) ?. tagName )
1215 : HeadingTag . includes ( ( t as Element ) ?. tagName )
16+ }
1317export const isParagraph = ( t : any ) => is ( t , { type : 'element' , tagName : 'p' } )
14- export const isTable = ( t : any ) : t is Element =>
15- is ( t , { type : 'element' , tagName : 'table' } ) &&
16- HeadingTag . includes ( ( t as Element ) . tagName )
18+ export function isTable ( t : any ) : t is Element {
19+ return (
20+ is ( t , { type : 'element' , tagName : 'table' } ) &&
21+ HeadingTag . includes ( ( t as Element ) . tagName )
22+ )
23+ }
1724export const isText = ( t : any ) : t is Text => is ( t , { type : 'text' } )
18- export const isUl = < T > ( t : T ) : t is T =>
19- is ( t , { type : 'element' , tagName : 'ul' } )
20- export const isBlockquote = ( t : any ) =>
21- is ( t , { type : 'element' , tagName : 'blockquote' } )
22- export const isImage = ( t : any ) : t is Element =>
23- is ( t , { type : 'element' , tagName : 'img' } )
25+ export function isUl < T > ( t : T ) : t is T {
26+ return is ( t , { type : 'element' , tagName : 'ul' } )
27+ }
28+ export function isBlockquote ( t : any ) {
29+ return is ( t , { type : 'element' , tagName : 'blockquote' } )
30+ }
31+ export function isImage ( t : any ) : t is Element {
32+ return is ( t , { type : 'element' , tagName : 'img' } )
33+ }
0 commit comments