export function proxyStorage ( storage ) { return new Proxy ( storage , { get , set } ) ; } function get ( target , property ) { if ( target [ property ] ) { return target [ property ] ; } if ( typeof property === 'number' ) { return getByIndex ( property , target ) ; } return target . getItem ( property ) ; } function getByIndex ( index , storage ) { const key = storage . key ( index ) ; return key ? storage . getItem ( key ) : null ; } function set ( target , property , value ) { const key = typeof property === 'number' ? target . key ( property ) : property ; if ( ! key ) { return false ; } target . setItem ( key , value ) ; return true ; }