Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should end method return a undefined? #55

Open
sosoba opened this issue Aug 17, 2022 · 3 comments
Open

Should end method return a undefined? #55

sosoba opened this issue Aug 17, 2022 · 3 comments

Comments

@sosoba
Copy link

sosoba commented Aug 17, 2022

Method end has a specific case when it return undefined.

public end(raw: boolean = false) {
  // ...  
    const matches = dataBitsLen.toString(16).match(/(.*?)(.{0,8})$/);
      if (matches === null) {
        return;
       }
  // ...  
}
``

Maybe this case should raise an exception?
@anmiles
Copy link

anmiles commented Oct 19, 2022

That was breaking change. Previously worked code that uses this library was not build because it didn't expect undefined there.
I assume this should increase major version or this change should be reverted.

@sosoba
Copy link
Author

sosoba commented Oct 21, 2022

Do you have data for which this case occurs? Maybe it's worth adding it in unit tests.

@anmiles
Copy link

anmiles commented Oct 21, 2022

const hash = new Md5().appendStr(str).end(false).toString()

Here in TS I need hash to exactly be a string. This was broken. However I temporarily replaced .toString() with as string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants