This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineComponent, ref, watch } from "vue"; | |
const Wow = defineComponent({ | |
props: { | |
limit: { | |
type: Number, | |
required: false, | |
default: 12, | |
}, | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function assertIAsset<T>(item: IAsset | IReference): item is IAsset { | |
return item.type === "typenavn her"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Construct a type with the properties of T and make the properties K optional. | |
*/ | |
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | |
// Example: | |
type Person = { | |
name: string; | |
age: number; | |
gender: "male" | "female"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function voidWait(timeToDelay: number): Promise<void> { | |
return new Promise((resolve) => setTimeout(resolve, timeToDelay)); | |
} | |
async function returnWait<T>(timeToDelay: number, returnValue: T): Promise<T> { | |
return new Promise((resolve) => setTimeout(() => resolve(returnValue), timeToDelay)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function getWeekNumberFromISOString(date: string): number { | |
const newYear = new Date(new Date(date).getFullYear(), 0, 1); | |
let day = newYear.getDay() - 1; // the day of week the year begins on | |
day = day >= 0 ? day : day + 7; | |
const dayNumber: number = | |
Math.floor( | |
(new Date(date).getTime() - | |
newYear.getTime() - | |
(new Date(date).getTimezoneOffset() - newYear.getTimezoneOffset()) * 60000) / | |
86400000 |
NewerOlder