Datasets:
Download scripts/utils.ts from labqoat/AsyncTool: direct link, hf CLI and curl.
- Browser
- Download file 543 Bytes
-
https://huggingface.co/datasets/labqoat/AsyncTool/resolve/main/scripts/utils.ts
- Command line
-
hf download hf://datasets/labqoat/AsyncTool/scripts/utils.ts
-
curl -L -o utils.ts https://huggingface.co/datasets/labqoat/AsyncTool/resolve/main/scripts/utils.ts
543 Bytes
| import z from "zod"; | |
| export const toolNameSchema = z.string().transform(toSnakeCase); | |
| export function toSnakeCase(str: string): string { | |
| return str | |
| .replace(/\s+/g, "_") // Replace spaces with underscores first | |
| .replace(/-+/g, "_") // Replace hyphens with underscores | |
| .replace(/([A-Z])/g, "_$1") // Add underscore before capital letters | |
| .toLowerCase() // Convert to lowercase | |
| .replace(/^_/, "") // Remove leading underscore | |
| .replace(/_+/g, "_"); // Replace multiple consecutive underscores with single underscore | |
| } | |