import { Node } from 'estree-walker' ; import { SvelteIdentifier , SvelteArrayPattern , SvelteObjectPattern , BaseNode } from '../interfaces' ; export function isMember ( parent , prop ) { return parent . type == 'MemberExpression' && prop == 'property' ; } export function isObjectKey ( parent , prop ) { return parent . type == 'Property' && prop == 'key' ; } export function isObjectValue ( parent , prop ) { return parent . type == 'Property' && prop == 'value' ; } export function isObjectValueShortHand ( property ) { const { value , key } = property ; return value && isIdentifier ( value ) && key . start === value . start && key . end == value . end ; } export function isText ( node ) { return node . type === 'Text' ; } export function attributeValueIsString ( attr ) { return attr . value . length !== 1 || attr . value [ 0 ] ?. type === 'Text' ; } export function isDestructuringPatterns ( node ) { return node . type === 'ArrayPattern' || node . type === 'ObjectPattern' ; } export function isIdentifier ( node ) { return node . type === 'Identifier' ; } export function getSlotName ( child ) { const slot = ( child . attributes as BaseNode [ ] ) ?. find ( ( a ) => a . name == 'slot' ) ; return slot ?. value ?. [ 0 ] . raw ; }