chore: void input edge case added to service

This commit is contained in:
Chesterkxng 2025-11-30 17:56:43 +01:00
parent 8cc7986c7f
commit ef034f2b8b

View File

@ -1,20 +1,13 @@
import { InitialValuesType } from './types'; import { InitialValuesType } from './types';
export function main(input: string, options: InitialValuesType): string { export function unicode(input: string, options: InitialValuesType): string {
return input; if (!input) return '';
} if (options.mode === 'encode') {
export function unicode(
input: string,
encode: boolean,
uppercase: boolean
): string {
if (encode) {
let result = ''; let result = '';
for (let i = 0; i < input.length; i++) { for (let i = 0; i < input.length; i++) {
let hex = input.charCodeAt(i).toString(16); let hex = input.charCodeAt(i).toString(16);
hex = ('0000' + hex).slice(-4); hex = ('0000' + hex).slice(-4);
if (uppercase) { if (options.uppercase) {
hex = hex.toUpperCase(); hex = hex.toUpperCase();
} }
result += '\\u' + hex; result += '\\u' + hex;