import { validateContent } from './validate' ; const requests = new Map < string , Promise < string > > ( ) ; export const getSvgContent = ( url ) => { let req = requests . get ( url ) ; if ( ! req ) { req = fetch ( url ) . then ( rsp => { if ( rsp . status <= 299 ) { return rsp . text ( ) ; } return Promise . resolve ( null ) ; } ) . then ( svgContent => validateContent ( svgContent ) ) ; requests . set ( url , req ) ; } return req ; } ;