{ lib, ... }: { toCamelCase = str: lib.throwIfNot (lib.isString str) "toCamelCase does only accepts string values, but got ${lib.typeOf str}" ( let separators = lib.splitStringBy ( prev: curr: builtins.elem curr [ "-" "_" " " ] ) false str; parts = lib.flatten ( map (lib.splitStringBy ( prev: curr: lib.match "[a-z]" prev != null && lib.match "[A-Z]" curr != null ) true) separators ); first = if lib.length parts > 0 then lib.toLower (lib.head parts) else ""; rest = if lib.length parts > 1 then builtins.map lib.toSentenceCase (lib.tail parts) else [ ]; in lib.concatStrings (map (lib.addContextFrom str) ([ first ] ++ rest)) ); }