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
export class SensitiveParameter<T> { | |
private readonly value: T | |
private readonly masked: string | |
constructor (value: T, masked: string = '***') { | |
this.value = value | |
this.masked = masked | |
} | |
/** |
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
const waitDOMContentLoaded = async () => { | |
await new Promise((resolve) => { | |
window.addEventListener('DOMContentLoaded', () => { | |
resolve() | |
}) | |
}) | |
} |
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
const waitLoaded = async () => { | |
await new Promise((resolve) => { | |
window.addEventListener('load', () => { | |
resolve() | |
}) | |
}) | |
} |
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
const sleep = async (ms) => { | |
return await new Promise(resolve => setTimeout(resolve, ms)) | |
} |
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
const sleep = async (ms)=> { | |
return await new Promise(resolve => setTimeout(resolve, ms)) | |
} |
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 { useMemo } from 'react' | |
import { useLocation } from 'react-router-dom' | |
/** | |
* @see https://v5.reactrouter.com/web/example/query-parameters | |
*/ | |
export const useQueryParams = (): URLSearchParams => { | |
const { search } = useLocation() | |
return useMemo(() => new URLSearchParams(search), [search]) | |
} |
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
((function () { | |
const backup = localStorage.getItem('backup') | |
const { data } = JSON.parse(backup) | |
const searchParams = new URLSearchParams(data) | |
const params = Object.fromEntries(searchParams) | |
console.log(params) | |
})() | |
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
const sleep = async (ms: number): Promise<void> => { | |
return await new Promise(resolve => setTimeout(resolve, ms)) | |
} |
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
function getRandomNumber ( | |
min: number, | |
max: number | |
): number { | |
min = Math.ceil(min) | |
max = Math.floor(max) | |
return Math.floor(Math.random() * (max - min)) + min | |
} |
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
const KATAKANA_PATTERN = /[\u30A1-\u30FA]/g | |
function convertKatakanaToHiragana (katakana: string): string { | |
return katakana.replace(KATAKANA_PATTERN, toHiragana) | |
} | |
function toHiragana (katakana: string): string { | |
const code = katakana.charCodeAt(0) - 0x60 | |
return String.fromCharCode(code) | |
} |
NewerOlder