This file contains 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, { useEffect, useState } from 'react'; | |
import { Image, ImageProps, ImageURISource } from 'react-native'; | |
import * as FileSystem from 'expo-file-system'; | |
import * as Crypto from 'expo-crypto'; | |
const getImageFileSystemKey = async (remoteURI: string) => { | |
const fileHash = await Crypto.digestStringAsync(Crypto.CryptoDigestAlgorithm.SHA256, remoteURI); | |
return `${FileSystem.cacheDirectory}${fileHash}`; | |
}; |
This file contains 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
let r = /(\w{2,4}-\d+)/gm; | |
let t = Array.from(document.getElementsByClassName('subject')).reduce((acc, node) => { | |
const match = node.innerText.match(r); | |
if (match && match.length > 0) { | |
return acc.add(...match.map((m) => m.toUpperCase())) | |
} | |
return acc; | |
}, new Set()); | |
console.log([...t].sort().join("\n")) |
This file contains 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains 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
/** | |
* Log a table in the console of all provided props and whether they have strict equality | |
* | |
* @param oldProps | |
* @param newProps | |
* @constructor | |
*/ | |
export const PropDiff = (oldProps, newProps) => { | |
let match = {}; | |
Object.keys(oldProps).forEach((oldPropKey) => { |
This file contains 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
/** | |
* Higher-order reducer factory for creating named reducers. | |
* Both params are required, and it will return your reducer or state. | |
* | |
* @param key | |
* @param reducer | |
* @returns {function} | |
*/ | |
const createNamedReducer = (key, reducer) => { | |
return (state, action) => { |
This file contains 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
/** | |
* Sleep timer that can also cancel the request | |
* | |
* @param ms | |
* @param isCancelled | |
* @returns {Promise<any>} | |
*/ | |
const sleep = (ms, isCancelled) => { | |
let timeoutHandler; |
This file contains 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
/** | |
* Higher order function that takes a param, and uses it as the first argument for another function | |
* | |
* @param key | |
* @param action | |
* @returns {function(...[*]): *} | |
*/ | |
const addParamToAction = (param, action) => { | |
return (...rest) => action(param, ...rest); | |
}; |