@@ -19,6 +19,7 @@ Ultra-lightweight string utilities with zero dependencies. Tree-shakeable, fully
1919- ⚡ ** ESM & CJS** - Works everywhere
2020- 🧪 ** 100% tested** - Reliable and production-ready
2121- 🔒 ** Type-safe** - Written in strict TypeScript with enhanced type inference and compile-time transformations
22+ - 🛡️ ** Null-safe** - All functions handle null/undefined gracefully without throwing errors
2223- 📝 ** Well documented** - JSDoc comments for all functions
2324
2425## Installation
@@ -901,15 +902,15 @@ const result = camelCase(userInput);
901902#### All Case Conversions Support Template Literals
902903
903904``` typescript
904- camelCase (" hello-world" ); // Type: "helloWorld"
905- kebabCase (" helloWorld" ); // Type: "hello-world"
906- snakeCase (" HelloWorld" ); // Type: "hello_world"
907- pascalCase (" hello-world" ); // Type: "HelloWorld"
908- constantCase (" helloWorld" ); // Type: "HELLO_WORLD"
909- dotCase (" HelloWorld" ); // Type: "hello.world"
910- pathCase (" helloWorld" ); // Type: "hello/world"
905+ camelCase (" hello-world" ); // Type: "helloWorld"
906+ kebabCase (" helloWorld" ); // Type: "hello-world"
907+ snakeCase (" HelloWorld" ); // Type: "hello_world"
908+ pascalCase (" hello-world" ); // Type: "HelloWorld"
909+ constantCase (" helloWorld" ); // Type: "HELLO_WORLD"
910+ dotCase (" HelloWorld" ); // Type: "hello.world"
911+ pathCase (" helloWorld" ); // Type: "hello/world"
911912sentenceCase (" hello-world" ); // Type: "Hello world"
912- titleCase (" hello-world" ); // Type: "Hello World"
913+ titleCase (" hello-world" ); // Type: "Hello World"
913914```
914915
915916#### Type-Safe Configuration Objects
@@ -943,11 +944,39 @@ type MethodNames = {
943944```
944945
945946Benefits:
947+
946948- ✅ ** Zero runtime cost** - All transformations happen at compile time
947949- ✅ ** Better IDE support** - Autocomplete shows exact transformed strings
948950- ✅ ** Type safety** - Catch typos and incorrect transformations during development
949951- ✅ ** Backward compatible** - Runtime strings work exactly as before
950952
953+ ### Null/Undefined Safety
954+
955+ All functions in nano-string-utils handle null and undefined inputs gracefully:
956+
957+ ``` typescript
958+ // No more runtime errors!
959+ slugify (null ); // Returns: null
960+ slugify (undefined ); // Returns: undefined
961+ slugify (" " ); // Returns: ""
962+
963+ // Consistent behavior across all functions
964+ isEmail (null ); // Returns: false (validation functions)
965+ words (null ); // Returns: [] (array functions)
966+ wordCount (null ); // Returns: 0 (counting functions)
967+
968+ // Safe to use without defensive checks
969+ const userInput = getUserInput (); // might be null/undefined
970+ const slug = slugify (userInput ); // Won't throw!
971+ ```
972+
973+ This means:
974+
975+ - ✅ ** No TypeErrors** - Functions never throw on null/undefined
976+ - ✅ ** Predictable behavior** - Consistent handling across all utilities
977+ - ✅ ** Cleaner code** - No need for defensive checks before calling functions
978+ - ✅ ** Zero performance cost** - Minimal overhead from null checks
979+
951980## Bundle Size
952981
953982Each utility is optimized to be as small as possible:
0 commit comments