import { DataProvider } from '../types' ; const fiveMinutes = 5 * 60 * 1000 ; param { DataProvider } dataProvider param { number } duration example export default ( dataProvider , duration = fiveMinutes ) : DataProvider => new Proxy ( dataProvider , { get : ( target , name ) => { if ( typeof name === 'symbol' ) { return ; } return ( resource , params ) => { if ( name === 'getList' || name === 'getMany' || name === 'getOne' ) { return dataProvider [ name ] ( resource , params ) . then ( response => { const validUntil = new Date ( ) ; validUntil . setTime ( validUntil . getTime ( ) + duration ) ; response . validUntil = validUntil ; return response ; } ) ; } return dataProvider [ name ] ( resource , params ) ; } ; } , } ) ;