This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// objectKey, encrypted | |
const decryptKey = await crypto.subtle.importKey( | |
"jwk", | |
{ | |
k: objectKey, | |
alg: "A128GCM", | |
ext: true, | |
key_ops: ["decrypt"], | |
kty: "oct", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export function useInterval(callback, delay) { | |
const savedCallback = React.useRef(); | |
React.useEffect(() => { | |
savedCallback.current = callback; | |
}, [callback]); | |
React.useEffect(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
export function useEventListener(eventName, handler, element = document) { | |
const savedCallback = React.useRef(); | |
React.useEffect(() => { | |
savedCallback.current = handler; | |
}, [handler]); | |
React.useEffect(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import useEventListener from './useEventListener'; | |
function getVisibilityPropertyNames() { | |
// Opera 12.10 and Firefox 18 and later support | |
if (typeof document.hidden !== 'undefined') { | |
return ['hidden', 'visibilitychange']; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const setCookie = (key, value, exdays) => { | |
const d = new Date(); | |
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000); | |
const expires = `expires=${d.toUTCString()}`; | |
document.cookie = `${key}=${value};${expires};secure;path=/`; | |
}; | |
export const getCookie = key => { | |
const name = `${key}=`; | |
const decodedCookie = decodeURIComponent(document.cookie); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import warning from 'warning'; | |
/* | |
* This is a dummy function to check if the function name has been altered by minification. | |
* If the function has been minified and NODE_ENV !== 'production', warn the user. | |
*/ | |
function isCrushed() {} | |
if ( | |
process.env.NODE_ENV !== 'production' && |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// returns object which is persisted in local storage | |
const getState = () => { | |
try { | |
const serializedState = localStorage.getItem('state'); | |
if (serializedState === null) { | |
return undefined; | |
} | |
return JSON.parse(serializedState); | |
} catch (err) { | |
return undefined; |