Extract scene functions to their respective modules (#208)

- Also, extract utilities into utils module -- capitalizeString, getDateTime, isInputLike
This commit is contained in:
Gasim Gasimzada 2020-01-06 20:24:54 +04:00 committed by GitHub
parent 01805f734d
commit 86a1c29eec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 695 additions and 530 deletions

25
src/utils.ts Normal file
View file

@ -0,0 +1,25 @@
export function getDateTime() {
const date = new Date();
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
const hr = date.getHours();
const min = date.getMinutes();
const secs = date.getSeconds();
return `${year}${month}${day}${hr}${min}${secs}`;
}
export function capitalizeString(str: string) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
export function isInputLike(
target: Element | EventTarget | null
): target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement {
return (
target instanceof HTMLInputElement ||
target instanceof HTMLTextAreaElement ||
target instanceof HTMLSelectElement
);
}