From 551b32a9ebba360d437003b73831f117172be06e Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sat, 24 Sep 2022 15:36:46 +0800 Subject: feat: Add capitalise --- apps/kit/src/lib/helpers.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'apps') diff --git a/apps/kit/src/lib/helpers.ts b/apps/kit/src/lib/helpers.ts index f0f60cd..c2a811e 100644 --- a/apps/kit/src/lib/helpers.ts +++ b/apps/kit/src/lib/helpers.ts @@ -1,8 +1,8 @@ -import {browser} from "$app/environment"; -import type {TimeEntryDto} from "$lib/models/TimeEntryDto"; -import type {UnwrappedEntryDateTime} from "$lib/models/UnwrappedEntryDateTime"; -import {logInfo} from "$lib/logger"; -import {Temporal} from "temporal-polyfill"; +import { browser } from "$app/environment"; +import type { TimeEntryDto } from "$lib/models/TimeEntryDto"; +import type { UnwrappedEntryDateTime } from "$lib/models/UnwrappedEntryDateTime"; +import { logInfo } from "$lib/logger"; +import { Temporal } from "temporal-polyfill"; export const EMAIL_REGEX = new RegExp(/^([a-z0-9]+(?:([._\-])[a-z0-9]+)*@(?:[a-z0-9]+(?:(-)[a-z0-9]+)?\.)+[a-z0-9](?:[a-z0-9]*[a-z0-9])?)$/i); export const URL_REGEX = new RegExp(/^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-.][a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/gm); @@ -99,7 +99,7 @@ export function merge_obj_arr(a: Array, b: Array, props: Array) if (a[start] === b[start]) { //pushing the merged objects into array - merge.push({...a[start], ...b[start]}); + merge.push({ ...a[start], ...b[start] }); } //incrementing start value start = start + 1; @@ -124,6 +124,10 @@ export function set_favicon(url: string) { } } +export function capitalise(value: string): string { + return value.charAt(0).toUpperCase() + value.slice(1); +} + export function set_emoji_favicon(emoji: string) { // Create a canvas element const canvas = document.createElement("canvas"); @@ -155,7 +159,7 @@ export function seconds_to_hour_minute(seconds: number) { const hours = Math.floor(seconds / (60 * 60)); seconds -= hours * (60 * 60); const minutes = Math.floor(seconds / 60); - return {hours, minutes}; + return { hours, minutes }; } export function get_query_string(params: any = {}): string { @@ -260,7 +264,7 @@ export function create_element(name: string, properties?: object, children?: Arr } export function get_element_position(element: HTMLElement | any) { - if (!element) return {x: 0, y: 0}; + if (!element) return { x: 0, y: 0 }; let x = 0; let y = 0; while (true) { @@ -271,7 +275,7 @@ export function get_element_position(element: HTMLElement | any) { } element = element.offsetParent; } - return {x, y}; + return { x, y }; } export function restrict_input_to_numbers(element: HTMLElement, specials: Array = [], mergeSpecialsWithDefaults: boolean = false): void { -- cgit v1.3