UNPKG

@wordpress/data

Version:
24 lines (19 loc) 372 B
let objectStorage; const storage = { getItem( key ) { if ( ! objectStorage || ! objectStorage[ key ] ) { return null; } return objectStorage[ key ]; }, setItem( key, value ) { if ( ! objectStorage ) { storage.clear(); } objectStorage[ key ] = String( value ); }, clear() { objectStorage = Object.create( null ); }, }; export default storage;