import { TypedHash } from '@pnp/common' ; param { string } str param { TypedHash } obj param { RegExp } regex export function replaceTokens ( str , obj , regex = /\{[A-Za-z]*\}/gm ) { return str . match ( regex ) . reduce ( ( s , value ) => { const field = value . substring ( 1 , value . length - 1 ) ; return s . replace ( value , obj [ field ] || '' ) ; } , str ) ; }