mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
* refactor: isolate network toast and login redirect to separate services * chore: remove accidentally committed sketch of a service * chore: tidying things up * feat: add `GlobalModule` encapsulating all global subscription services * remove angular build cache when building deps * chore: fix more issues found while testing * chore: fix issues reported by testing * chore: fix template error * chore: fix server-info * chore: fix server-info * fix: switch to Observable to fix race conditions * fix embassy name display on load * update patchdb * clean up patch data watch Co-authored-by: Lucy Cifferello <12953208+elvece@users.noreply.github.com>
39 lines
988 B
TypeScript
39 lines
988 B
TypeScript
export function isObject(val: any): boolean {
|
|
return val && typeof val === 'object' && !Array.isArray(val)
|
|
}
|
|
|
|
export function isEmptyObject(obj: object): boolean {
|
|
return obj === undefined || !Object.keys(obj).length
|
|
}
|
|
|
|
export function pauseFor(ms: number): Promise<void> {
|
|
return new Promise(resolve => setTimeout(resolve, ms))
|
|
}
|
|
|
|
export function capitalizeFirstLetter(string: string): string {
|
|
return string.charAt(0).toUpperCase() + string.slice(1)
|
|
}
|
|
|
|
export function exists<T>(t: T | undefined): t is T {
|
|
return t !== undefined
|
|
}
|
|
|
|
export function debounce(delay: number = 300): MethodDecorator {
|
|
return function (
|
|
target: any,
|
|
propertyKey: string | symbol,
|
|
descriptor: PropertyDescriptor,
|
|
) {
|
|
const timeoutKey = Symbol()
|
|
|
|
const original = descriptor.value
|
|
|
|
descriptor.value = function (...args) {
|
|
clearTimeout(this[timeoutKey])
|
|
this[timeoutKey] = setTimeout(() => original.apply(this, args), delay)
|
|
}
|
|
|
|
return descriptor
|
|
}
|
|
}
|