How to get the determined attributes from a mark

I realize this is an old post however my code may be of help to someone with this issue. Note that I am very new to Prosemirror, so there may well be better ways to accomplish this.

/** Get mark at `pos` for `markType`
 *
 *  @param {Object} view - EditorView
 *  @param {Number} pos - position. ex. selection.from
 *  @param {Object} markType - the MarkType whose Mark you want. ex. view.state.schema.marks.link
 *
 *  @return { start, link, mark } if mark present, else undefined
 *         ex: { $pos:  ResolvedPos for pos param
 *               start: { index, node, offset } for child node after $pos.parent
 *               mark: { attrs: { href: "http://foo.com", title: null }
 *                       type: MarkType
 *                     }
 *             }
 */
function getMarkAtPos( view, pos, markType ){
const doc = view.state.tr.doc,
      $pos = doc.resolve( pos ),
      start = $pos.parent.childAfter( $pos.parentOffset )

if ( start.node ){   // node is a TextNode in our use case.
    const mark = start.node.marks.find( ( mark ) => mark.type === markType )
    if ( mark ){
        // mlog.note( 'getMarkAtPos() mark:', mark )
        return { $pos, start, mark }
    }
}
}