From 597be0f9790ae5e67057537db704686642ad0a18 Mon Sep 17 00:00:00 2001
From: Hugues Chocart <chocart.hugues@icloud.com>
Date: Sat, 11 Jan 2025 23:58:20 +0100
Subject: [PATCH 1/2] fix: toCamel

---
 src/types.js | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/types.js b/src/types.js
index 7c7c2b93..45c8b625 100644
--- a/src/types.js
+++ b/src/types.js
@@ -316,9 +316,16 @@ function arrayParserLoop(s, x, parser, typarray) {
 }
 
 export const toCamel = x => {
-  let str = x[0]
-  for (let i = 1; i < x.length; i++)
-    str += x[i] === '_' ? x[++i].toUpperCase() : x[i]
+  let str = x[0] === '_' ? '' : x[0]
+
+  for (let i = 1; i < x.length; i++) {
+    if (x[i] === '_') {
+      while (i < x.length && x[i] === '_') i++
+      if (i < x.length) str += x[i].toUpperCase()
+    } else {
+      str += x[i]
+    }
+  }
   return str
 }
 

From 8e179c420fefd8db6b652ece60501b2c7cbf4fd3 Mon Sep 17 00:00:00 2001
From: Hugues Chocart <chocart.hugues@icloud.com>
Date: Sun, 12 Jan 2025 00:26:12 +0100
Subject: [PATCH 2/2] fix toCamel + toPascal

---
 src/types.js | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/types.js b/src/types.js
index 45c8b625..deb689db 100644
--- a/src/types.js
+++ b/src/types.js
@@ -316,24 +316,27 @@ function arrayParserLoop(s, x, parser, typarray) {
 }
 
 export const toCamel = x => {
-  let str = x[0] === '_' ? '' : x[0]
-
+  let str = x[0]
   for (let i = 1; i < x.length; i++) {
-    if (x[i] === '_') {
-      while (i < x.length && x[i] === '_') i++
-      if (i < x.length) str += x[i].toUpperCase()
-    } else {
+    if (x[i] === '_' && i + 1 < x.length) {
+      str += x[++i].toUpperCase()
+    } else if (x[i] !== '_') {
       str += x[i]
-    }
+    }   
   }
-  return str
+  return str 
 }
 
 export const toPascal = x => {
   let str = x[0].toUpperCase()
-  for (let i = 1; i < x.length; i++)
-    str += x[i] === '_' ? x[++i].toUpperCase() : x[i]
-  return str
+  for (let i = 1; i < x.length; i++) {
+    if (x[i] === '_' && i + 1 < x.length) {
+      str += x[++i].toUpperCase()
+    } else if (x[i] !== '_') {
+      str += x[i]
+    }   
+  }
+  return str 
 }
 
 export const toKebab = x => x.replace(/_/g, '-')