Files
Brandon Thomas 82effe0ce9 add nx for javascript monorepos and move 3d under it (#497)
this required the following:

- downgrading nx react (19 -> 18.2)
- .npmrc credentials for fontawesome
- installing a lot of nx plugins from the vanilla config
- removing kalidokit vendored code and all references to it
2025-04-10 23:15:23 -04:00

67 lines
1.6 KiB
TypeScript

import { Params } from "@remix-run/react";
import { JobStatus } from "./enums";
import deepEqual from "deep-equal";
export const isObjectSerializable = (obj: object) => {
return deepEqual(obj, deepCopySerializableObjects(obj));
};
export const deepCopySerializableObjects = (obj: object) => {
return JSON.parse(JSON.stringify(obj));
};
export const kebabCase = (str: string) =>
str
.replace(/([a-z])([A-Z])/g, "$1-$2")
.replace(/[\s_]+/g, "-")
.toLowerCase();
export const getCurrentLocationWithoutParams = (
path: string,
params: Readonly<Params<string>>,
) => {
let result = path;
Object.keys(params).forEach((key) => {
result = result.replace("/" + params[key] || "", "");
});
if (result[result.length - 1] !== "/") result = result + "/";
return result;
};
export const isJobStatusTerminal = (curr: JobStatus) => {
if (
curr === JobStatus.PENDING ||
curr === JobStatus.STARTED ||
curr === JobStatus.ATTEMPT_FAILED
) {
return false;
}
return true;
};
export const isNumberString = (value: string) => {
return !isNaN(Number(value));
};
export const isJobStatusError = (curr: JobStatus) => {
if (
curr === JobStatus.ATTEMPT_FAILED ||
curr === JobStatus.COMPLETE_FAILURE ||
curr === JobStatus.DEAD
) {
return true;
}
return false;
};
export const getFileName = (file: File) => {
return file.name.substring(0, file.name.lastIndexOf("."));
};
export const getFileExtension = (file: File) => {
return file.name.substring(file.name.lastIndexOf("."));
};
export const getFileTypesFromEnum = (enumOfTypes: object) => {
return Object.keys(enumOfTypes);
};