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
| /** | |
| * Detect words in a paragraph. | |
| * @type {RegExp} ['word', 'word', ...] | |
| */ | |
| export const WORDS = /[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g | |
| /** | |
| * Detect a valid Venezuelan phone number (area code included) | |
| * @type {RegExp} | |
| */ |
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
| 🇻🇪 Venezuela | |
| const Venezuela = [ | |
| { | |
| "iso_31662": "VE-X", | |
| "estado": "Amazonas", | |
| "capital": "Puerto Ayacucho", |
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 { useEffect, useState } from "react"; | |
| type UseTextSelectionReturn = { | |
| text: string; | |
| rects: DOMRect[]; | |
| ranges: Range[]; | |
| selection: Selection | null; | |
| }; | |
| const getRangesFromSelection = (selection: Selection): Range[] => { |
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 { useEffect, useState } from "react"; | |
| interface LocationOptions { | |
| enableHighAccuracy?: boolean; | |
| timeout?: number; | |
| maximumAge?: number; | |
| } | |
| interface LocationState { | |
| coords: { |
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 { useEffect, useRef } from "react"; | |
| type GestureType = | |
| | "swipeUp" | |
| | "swipeDown" | |
| | "swipeLeft" | |
| | "swipeRight" | |
| | "tap" | |
| | "pinch" | |
| | "zoom"; |
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 { useCallback, useEffect, useState } from "react"; | |
| type FetchState<T> = { | |
| data: T | null; | |
| isLoading: boolean; | |
| error: Error | null; | |
| isCached: boolean; | |
| refetch: () => void; | |
| }; |
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 { useEffect, useState } from "react"; | |
| function useLocalStorage() { | |
| const [loadingStates, setLoadingStates] = useState<Map<string, boolean>>( | |
| new Map() | |
| ); | |
| const setStorageValue = <T>(key: string, value: T) => { | |
| try { | |
| window.localStorage.setItem(key, JSON.stringify(value)); |
NewerOlder