(storage: Storage)
| 49 | } |
| 50 | |
| 51 | export function wrapStorage(storage: Storage) { |
| 52 | const props = { |
| 53 | clear: storage.clear.bind(storage), |
| 54 | getItem: storage.getItem.bind(storage), |
| 55 | key: storage.key.bind(storage), |
| 56 | removeItem: storage.removeItem.bind(storage), |
| 57 | setItem: storage.setItem.bind(storage), |
| 58 | }; |
| 59 | |
| 60 | return new Proxy(storage, { |
| 61 | get(target, prop) { |
| 62 | if (prop in props) { |
| 63 | return props[prop as keyof typeof props]; |
| 64 | } else { |
| 65 | return target[prop as keyof typeof target]; |
| 66 | } |
| 67 | }, |
| 68 | |
| 69 | set(target, prop, value) { |
| 70 | if (prop in props) { |
| 71 | return (props[prop as keyof typeof props] = value); |
| 72 | } else { |
| 73 | return (target[prop as keyof typeof target] = value); |
| 74 | } |
| 75 | }, |
| 76 | }); |
| 77 | } |
| 78 | |
| 79 | export function isCtrlDown(event: KeyboardEvent | MouseEvent) { |
| 80 | return event.ctrlKey || event.metaKey; |
no outgoing calls
no test coverage detected