sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh
| import type { Prettify } from 'ts-essentials'; | |
| export type Result<T = unknown, E = unknown> = Success<T> | Failure<E>; | |
| export interface Success<T> { | |
| kind: 'success'; | |
| value: T; | |
| } | |
| export interface Failure<E> { |
| /** | |
| * If argument is a string, try to parse as JSON. | |
| * Otherwise return null. | |
| */ | |
| export function parseOrNull(raw: unknown) { | |
| if (!raw) return null | |
| if (typeof raw === 'string') { | |
| try { | |
| return JSON.parse(raw) |
| const uuid = () => Date.now().toString(36) + Math.random().toString(36).substr(2); |
| enum LocalStorageExpired { | |
| INFINITE = 'INFINITE', | |
| LOGOUT = 'LOGOUT', | |
| } | |
| class LocalStorageService { | |
| prefix = 'GG_'; | |
| get<T extends unknown>(key: string, defaultValue: T): T { | |
| try { |
| // Who needs eventemitter3, mitt, or some other library when you can use native DOM APIs? 😁 | |
| let eventEmitter = new EventTarget(); | |
| eventEmitter.addEventListener('test', console.log); // CustomEvent { type: 'test', detail: 123, ... } | |
| eventEmitter.dispatchEvent(new CustomEvent('test', { detail: 123 })); |
| function createRoundedRectPath(x, y, width, height, radius) { | |
| return ( | |
| // Move to position, offset by radius in x direction | |
| "M" +(x + radius) + "," + y | |
| // Draw a horizontal line to the top right curve start | |
| + "h" + (width - 2 * radius) | |
| // Draw the top right corner curve | |
| + "a" + radius + "," + radius + " 0 0 1 " + radius + "," + radius | |
| // Draw a vertical line to the bottom right corner | |
| + "v" + (height - 2 * radius) |
| import axios from 'axios'; | |
| import { LANGUAGE_NAME, REFRESH_TOKEN_IN_STORE, TOKEN_NAME_IN_STORE } from '../constants/api'; | |
| import { getBrowserLang, setTokens } from './GlobalHelper'; | |
| import { logoutDispatch } from './StoreHelper'; | |
| import LocalStorageHelper from './LocalStorageHelper'; | |
| import { BACKEND_ROUTES } from '../constants/routes'; | |
| export const API_REQUEST_AUTH_USER_LOGIN_URL = '/users/login'; | |
| export const API_REQUEST_AUTH_USER_LOGIN_SOCIAL_URL = '/login/social'; |
| import { createAction, props } from '@ngrx/store'; | |
| import { Joke } from 'src/app/models'; | |
| export const createJokeSuccessAction = (actionType: string) => | |
| createAction(actionType, props<{ jokes: Joke[] }>()); | |
| export const createJokeFailureAction = (actionType: string) => | |
| createAction(actionType, props<{ error: any }>()); | |
| export const loadAll = createAction('[Jokes Page] Load All'); |