mirror of
https://github.com/Qortal/q-tube.git
synced 2025-11-13 19:07:04 +00:00
Refactored constants/index.ts into Identifiers.ts, Categories.ts, and Misc.ts. Regular expressions that titles allow all use new variable in Misc.ts for consistency and ease of editing it. New Characters are allowed in titles. Categories sorted by name, "Other" is always at end of list. New Categories such as Qortal under Education have been added Title prefix TextField added that starts all video titles with the entered value.
29 lines
690 B
TypeScript
29 lines
690 B
TypeScript
import * as colorsys from "colorsys";
|
|
|
|
export const truncateNumber = (value: string | number, sigDigits: number) => {
|
|
return Number(value).toFixed(sigDigits);
|
|
};
|
|
|
|
export const changeLightness = (hexColor: string, amount: number) => {
|
|
const hsl = colorsys.hex2Hsl(hexColor);
|
|
hsl.l += amount;
|
|
return colorsys.hsl2Hex(hsl);
|
|
};
|
|
export const removeTrailingZeros = (s: string) => {
|
|
return Number(s).toString();
|
|
};
|
|
|
|
export const setNumberWithinBounds = (
|
|
num: number,
|
|
minValue: number,
|
|
maxValue: number
|
|
) => {
|
|
if (num > maxValue) return maxValue;
|
|
if (num < minValue) return minValue;
|
|
return num;
|
|
};
|
|
|
|
export const numberToInt = (num: number) => {
|
|
return Math.floor(num);
|
|
};
|