You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO items should be gneric not any and the output should be the same type as the input
importtype{SortProperty,StatusFilter}from'$lib/types/entry'importtype{SortDirection}from'$lib/types/enums'import{format}from'date-fns'// solution inspired by https://www.designcise.com/web/tutorial/how-to-fix-replaceall-is-not-a-function-javascript-error// implementation inspired by https://futurestud.io/tutorials/node-js-string-replace-all-appearances// TODO replace with magic regexexportfunctiongetSlug(str: string){if(!str)return''constslug=str.trim().toLowerCase()// remove all chars which aren't characters, numbers or spaces.replace(/[^a-zA-Z0-9\s]+/g,'')// replace all spaces with dashes.replace(/\s+/g,'-')returnslug}// Won't be tested// TODO items should be gneric not any and the output should be the same type as the inputexportfunctiongetRandomItems(items: any[],amount: number){returnitems.sort(()=>0.5-Math.random()).slice(0,amount)}exportfunctionformatDate(date: Date): string{returnformat(newDate(date),'yyyy-MM-dd')}exportfunctionsortAlphabetical(a: string,b: string): number{returna.localeCompare(b)}exportfunctionsortDate(a: Date,b: Date): number{returnnewDate(b).valueOf()-newDate(a).valueOf()}exportfunctionsortNumber(a: number,b: number): number{returnb-a}exportfunctionenumToArray(rawEnum: SortDirection|StatusFilter|SortProperty): {display: string;key: string}[]{returnObject.keys(rawEnum).map((key)=>{return{display: key,key: rawEnum[key]}})}exportfunctionsetParam(key: string,value: string){consturl=newURL(window.location.toString())url.searchParams.set(key,value)window.history.pushState({},'',url.href)}
2d25563af7bb9d2de4a8bc0c6593726558267551
The text was updated successfully, but these errors were encountered:
items should be gneric not any and the output should be the same type as the input
harambasic.de/src/lib/util/helper.ts
Line 21 in 7844724
2d25563af7bb9d2de4a8bc0c6593726558267551
The text was updated successfully, but these errors were encountered: