Skip to content

Consider using more normal casing rules #56

Open

Description

@domenic

Since I'm filing issues with suggested breaking changes anyway (#55), I thought I'd file this one as well...

It's very confusing for me that this library doesn't follow the usual camelcasing rules of uppercasing every word after the first. (Seen e.g. in standard APIs like Uint16Array.) Instead, it seems to lowercase words if they follow a number. This has led to a number of runtime failures for me and my LLMs as we try to write code against the library.

It would be nice if this library updated its method names, e.g. fromBase32hex -> fromBase32Hex, windows1252fromString -> windows1252FromString, etc.

Activity

  1. ChALkeR commented on Jan 29, 2026

    @ChALkeR
    Collaborator

    This can be done in a non-breaking way (aliases + typedoc-deprecations), but there was some logic behind that, which I need to recheck

  2. ChALkeR commented on Jan 29, 2026

    @ChALkeR
    Collaborator

    All of the methods follow the same pattern: letters directly after digits are not capitalized.

    There are a lot of digits in the middle of function names, and capitalizing letters after those hurts readability for humans.
    Even in the examples above: in fromBase32Hex / windows1252FromString the first letter after digits reads as a contiuation of the digits because of the same height and being valid hex in some cases.

    Case switching in camelcasing is needed for parts separation, and a lowercase letter after digits better visually separates the part from digits than an uppercase letter.

    LLMs should be using .d.ts?

  3. domenic commented on Jan 29, 2026

    @domenic
    Author

    capitalizing letters after those hurts readability for humans.

    I don't think that's true... I think breaking from convention hurts readability more. It certainly makes me visually stumble as I end up having to internalize the rules which are unique to this library over the ones that the rest of the JS ecosystem uses.

    LLMs should be using .d.ts?

    A lot of the times they just assume that if one method exists, the others must as well. They'll figure it out and go consult the .d.ts after they get errors, but it's extra tokens wasted.

  4. ChALkeR commented on Jan 31, 2026

    @ChALkeR
    Collaborator

    I still don't buy the llms argument, it would be void anyway in less than several months

    Throwing off humans is more significant, and with introduction of isomorphic* the casing would indeed look inconsistent (as there are no numbers) and it'll have FromString and ToString per the current naming scheme

    I need to think about it

    Affected methods:

    fromBase32hex
    fromBase58checkSync
    fromBase58check
    fromBase58xrp
    fromBase64any
    fromBase64url
    fromBech32m
    latin1fromString # likely will be soft-deprecated anyway
    latin1toString # likely will be soft-deprecated anyway
    makeBase58check
    toBase32hex
    toBase58checkSync
    toBase58check
    toBase58xrp
    toBase64url
    toBech32m
    utf16fromStringLoose
    utf16fromString
    utf16toStringLoose
    utf16toString
    utf8fromStringLoose
    utf8fromString
    utf8toStringLoose
    utf8toString
    windows1252fromString
    windows1252toString
    
  5. ChALkeR commented on Feb 1, 2026

    @ChALkeR
    Collaborator

    Some of them seem strange and more confusing when capitalizing the other way:

    fromBase32Hex
    fromBase58CheckSync
    fromBase58Check
    fromBase58Xrp
    fromBase64Any
    fromBase64Url
    fromBech32M
    ...
    

    The encoding is "base64url", its camelcase should be Base64url, not Base64Url
    Also ref: sindresorhus/camelcase#77, sindresorhus/camelcase#112, https://github.com/sindresorhus/camelcase#capitalizeafternumber

    fromBase32hex -> fromBase32Hex

    Same for base32hex, it's the encoding name, 32 is not a divisor, the encoding name shouldn't be capitalized to Base32Hex. Like base64url should not be capitalized to Base64Url (Url casing itself is very confusing).

    i.e. fromBase32hex is from_base32hex, not from_base32_hex

    @domenic wdyt on that ^


    So what remains are only:

    latin1fromString # likely will be soft-deprecated anyway
    latin1toString # likely will be soft-deprecated anyway
    utf16fromStringLoose
    utf16fromString
    utf16toStringLoose
    utf16toString
    utf8fromStringLoose
    utf8fromString
    utf8toStringLoose
    utf8toString
    windows1252fromString
    windows1252toString
    
  6. domenic commented on Feb 2, 2026

    @domenic
    Author

    Some of the

    I just disagree with this assessment. The examples you list all look natural, because the follow the casing rules that I've used in JavaScript for the last ~15 years.

    I agree the rules for how to use camel-casing when you have a predefined term that is often written using another case can be tricky. (E.g., base64url often written using squishedtogethercase.) I would still mentally stumble as I'd have to combine together my usual JavaScript instincts of camel casing with this domain-specific choice to use squishedtogethercase. So my preference would be to stick to the JavaScript standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions