RegExp Query:
([\(\)\._a-zA-Z]*)\s\?\?=\s([\._a-zA-Z\(\)]*)
RegExp Substitue With:
$1 = ($1 === null || $1 === undefined) ? $2 : $1
Example:
function gitacp() { | |
if git diff --quiet && git diff --cached --quiet; then | |
echo "✅ No changes to commit. Exiting." | |
return 0 | |
fi | |
if [ -z "$1" ]; then | |
echo "Usage: gitac \"commit message\"" | |
return 1 | |
fi |
//https://www.youtube.com/watch?v=AdmGHwvgaVs&t=414s | |
const catchErrorTyped = <T, E extends new (message?: string) => | |
Error>( | |
p: Promise<T>, | |
customErrors?: E[] | |
):Promise<(undefined| T)[] | [E]> => { | |
return p.then((data:T) => { | |
return [undefined, data]; |
import mockRouter from "next-router-mock"; | |
jest.mock("next/router", () => jest.requireActual("next-router-mock")); | |
describe("Page useRouter hook", () => { | |
it("renders", () => { | |
mockRouter.push("/home?with=query"); | |
//... | |
}); |
import useSWRInfinite from "swr/infinite"; | |
jest.mock("swr/infinite"); | |
describe("Page with SWRInfinite", () => { | |
it("renders", () => { | |
(useSWRInfinite as jest.Mock).mockResolvedValue({ | |
data: [{ data: [] }], | |
error: null, | |
}); |
/** | |
* Based on this article | |
* https://medium.com/geekculture/using-zoho-api-for-leads-in-node-js-ea204e98d41b | |
*/ | |
/** | |
* IMPORTANT: pay attention to the super-domain ("com", "eu", etc). | |
* Must be the same you used for the client registration. | |
* Otherwise will cause: `{ "error": "invalid_client" }` | |
*/ |
import enumToArray from "./enumToArray"; | |
enum Numbers { | |
One = 'One', | |
Two = 'Two', | |
Three = 'Three' | |
}; | |
enum Empty {} |
RegExp Query:
([\(\)\._a-zA-Z]*)\s\?\?=\s([\._a-zA-Z\(\)]*)
RegExp Substitue With:
$1 = ($1 === null || $1 === undefined) ? $2 : $1
Example:
/** @type {import('next').NextConfig} */ | |
const nextConfig = { | |
reactStrictMode: true, | |
pageExtensions: [ | |
'mdx', | |
'md', | |
'jsx', | |
'tsx', | |
'ts' |
/** | |
* @function fetchRates | |
* @description fetch currencies rate | |
* @param {string} [url='https://bank.gov.ua/NBUStatService/v1/statdirectory/exchange?json'] - currencies rate api endpoint | |
* @returns {promise} | |
* @example | |
* let rates = []; | |
* fetchRates().then(newRates => { | |
* rates = newRates; | |
* }); |
const random = (max) => { | |
return Math.floor(Math.random() * max); | |
}; | |
const getRandomAvaURL = () => { | |
const source = 'https://randomuser.me/api/portraits'; | |
const gender = ['women', 'men'][random(2)]; | |
const count = 100; | |
const id = random(count); | |
const extention = 'jpg'; |