import { JSCodeshift } from 'jscodeshift' ; import { Collection } from 'jscodeshift/src/Collection' ; export type ImportLocalImported = { local ? : string ; imported : string ; } ; export const membersMatchingPred = ( j , collection , pred , removeMatches = false ) : ImportLocalImported [ ] => { const results = [ ] ; const matches = collection . find ( j . ImportSpecifier ) . filter ( pred ) . forEach ( ( x ) => { if ( x . node . local || x . node . imported ) { results . push ( { local : x . node . local ?. name , imported : x . node . imported . name } ) ; } } ) ; if ( removeMatches ) { matches . remove ( ) ; } return results ; } ;