mirror of
https://github.com/rjNemo/deno_hello
synced 2026-06-06 01:56:40 +00:00
15 lines
446 B
TypeScript
15 lines
446 B
TypeScript
import { ValidationError } from "./validation.ts";
|
|
import { localesSize } from "./data.ts";
|
|
|
|
/**
|
|
* Display the iconic Hello, World
|
|
*/
|
|
export const sayHello = (id?: number) => {
|
|
if (id && idInValidRange(id)) {
|
|
throw new ValidationError(`Invalid index: ${id}`);
|
|
}
|
|
// const hello = getLocaleByNumber(id);
|
|
return (id === 5) ? "Bonjour le monde" : "Hello, World!";
|
|
};
|
|
|
|
const idInValidRange = (id: number) => id < 1 || id >= localesSize;
|