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
| function compareBranches(arr) { | |
| // Helper function to traverse the tree recursively | |
| function sum(node) { | |
| if (!node) { | |
| return 0; | |
| } | |
| return node + sum(arr.shift() && arr.shift() ? node * 2 : null) + sum(arr.shift() && arr.shift() ? node * 2 + 1 : null); | |
| } | |
| const leftSum = sum(arr.shift()); |
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
| function flatten(collection: any[]) { | |
| return collection.reduce((result, current) => { | |
| let value = current | |
| if (Array.isArray(current)) { | |
| value = flatten(current) | |
| } | |
| return result.concat(value) | |
| }, []) | |
| } |
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
| type Primitive = string | number | boolean | null | |
| type JSONObject = { [k: string]: JSONValue } | |
| type JSONArray = JSONValue[] | |
| type JSONValue = Primitive | JSONArray | JSONObject |
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
| const useKeyPress = (targetKey) => { | |
| const [keyPressed, setKeyPressed] = React.useState(false); | |
| const downHandler = ({ key }) => { | |
| if (key === targetKey) setKeyPressed(true); | |
| }; | |
| const upHandler = ({ key }) => { | |
| if (key === targetKey) setKeyPressed(false); | |
| }; | |
| React.useEffect(() => { | |
| window.addEventListener("keydown", downHandler); |
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
| const options = [ | |
| "quarterpipe", | |
| "big hubba", | |
| "small hubba", | |
| "flatrail", | |
| "vault", | |
| "vault gap", | |
| "stairs", | |
| "ledge", | |
| "manual pad", |
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 { IS_IE } from '../view/ui/styles/constants'; | |
| const getByteArray = arquivo => { | |
| const byteCharacters = atob(arquivo); | |
| const byteNumbers = new Array(byteCharacters.length); | |
| for (let i = 0; i < byteCharacters.length; i++) { | |
| byteNumbers[i] = byteCharacters.charCodeAt(i); | |
| } |
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 default function hexToRgbA(hex, alpha = 1) { | |
| var c; | |
| if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)) { | |
| c = hex.substring(1).split(''); | |
| if (c.length == 3) { | |
| c = [c[0], c[0], c[1], c[1], c[2], c[2]]; | |
| } |
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 default str => | |
| str | |
| .toLowerCase() | |
| .replace(/[àÀáÁâÂãäÄÅåª]+/g, 'a') // Special Characters #1 | |
| .replace(/[èÈéÉêÊëË]+/g, 'e') // Special Characters #2 | |
| .replace(/[ìÌíÍîÎïÏ]+/g, 'i') // Special Characters #3 | |
| .replace(/[òÒóÓôÔõÕöÖº]+/g, 'o') // Special Characters #4 | |
| .replace(/[ùÙúÚûÛüÜ]+/g, 'u') // Special Characters #5 | |
| .replace(/[ýÝÿŸ]+/g, 'y') // Special Characters #6 | |
| .replace(/[ñÑ]+/g, 'n') // Special Characters #7 |
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
| /** | |
| * @param date datetime object | |
| * | |
| * @returns string | |
| * | |
| * ex menos de 1 min: (< 1 m) | |
| * menos de 1 hora: (35 m) | |
| * menos de 1 dia: (16 h) | |
| * menos de 1 semana: (5 D) | |
| * menos de 1 mês: (2 sem) |
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
| class Enum { | |
| constructor() { | |
| this.innerEnum = {}; | |
| } | |
| declare({ key, value, description, isFlag = false }) { | |
| this.innerEnum[key] = { | |
| key, | |
| id: value, | |
| description, |
NewerOlder