Add sources for external code
This commit is contained in:
parent
26b6c63caf
commit
5b6f869962
1 changed files with 4 additions and 0 deletions
|
@ -5,6 +5,7 @@ export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs));
|
return twMerge(clsx(inputs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://perryjanssen.medium.com/getting-random-tracks-using-the-spotify-api-61889b0c0c27
|
||||||
export function getRandomSearch() {
|
export function getRandomSearch() {
|
||||||
// A list of all characters that can be chosen.
|
// A list of all characters that can be chosen.
|
||||||
const characters = 'abcdefghijklmnopqrstuvwxyz';
|
const characters = 'abcdefghijklmnopqrstuvwxyz';
|
||||||
|
@ -26,6 +27,7 @@ export function getRandomSearch() {
|
||||||
return randomSearch;
|
return randomSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Created using Claude 3.5 Sonett
|
||||||
export function shuffleObjectValues<T extends object>(arr: Array<T>): Array<T> {
|
export function shuffleObjectValues<T extends object>(arr: Array<T>): Array<T> {
|
||||||
// Create a copy of the array
|
// Create a copy of the array
|
||||||
const copy = structuredClone(arr);
|
const copy = structuredClone(arr);
|
||||||
|
@ -52,6 +54,7 @@ export function shuffleObjectValues<T extends object>(arr: Array<T>): Array<T> {
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/12646864
|
||||||
export function shuffleArray<T>(array: T[]): T[] {
|
export function shuffleArray<T>(array: T[]): T[] {
|
||||||
for (let i = array.length - 1; i >= 0; i--) {
|
for (let i = array.length - 1; i >= 0; i--) {
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
@ -61,6 +64,7 @@ export function shuffleArray<T>(array: T[]): T[] {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Created using Claude 3.5 Sonett
|
||||||
export function truncate(text: string, maxLength: number): string {
|
export function truncate(text: string, maxLength: number): string {
|
||||||
// Return original text if it's shorter than or equal to maxLength
|
// Return original text if it's shorter than or equal to maxLength
|
||||||
if (text.length <= maxLength) {
|
if (text.length <= maxLength) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue