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

Method chaining when using update #100

Closed
ADTC opened this issue Sep 20, 2022 · 7 comments
Closed

Method chaining when using update #100

ADTC opened this issue Sep 20, 2022 · 7 comments

Comments

@ADTC
Copy link

ADTC commented Sep 20, 2022

Is your feature request related to a problem? Please describe.
Method chaining can help simplify code.

Describe the solution you'd like
I have a code block like this:

const hash256 = (str) => {
    const shaObj = new jsSHA('SHA-256', 'TEXT');
    shaObj.update(str);
    return shaObj.getHash('HEX');
}

I thought I could simplify it like this:

const hash256 = (str) => new jsSHA('SHA-256', 'TEXT').update(str).getHash('HEX');

But it won't be possible since update returns void and not this.

Perhaps it could return this so that chaining becomes possible.

@Caligatio
Copy link
Owner

This looks super easy to do and would give me an excuse to push v3.3.0.

I'm almost done with my 3-month international move so I can't give any firm timelines. I'll either be able to get it done ASAP (I finally have my computer again!) or it might have to wait a bit as there are other major life events in the pipeline.

@Caligatio
Copy link
Owner

As with all things Typescript/Javascript, this is turning out to be a slightly bigger problem than anticipated for unrelated reasons: eslint has been heavily updated since I last used it so my use of the any type in key areas is causing an unholy amount of errors.

I need to scrub the codebase and try to switch my any types to unknown types... which might take a bit :(

@ADTC
Copy link
Author

ADTC commented Oct 8, 2022

Thank you for updating me!

@Caligatio
Copy link
Owner

I got lazy and squelched the problematic eslint options :)

This should be now implemented in 2c60363

@ADTC
Copy link
Author

ADTC commented Oct 9, 2022

Amazing! Thank you. Which version will it be released in?

@ADTC
Copy link
Author

ADTC commented Oct 9, 2022

Btw, may I suggest updating some examples in the readme to include this alternative version? For example:

const hash = new jsSHA("SHA-512", "TEXT", { encoding: "UTF8" })
    .update("This is a ")
    .update("test")
    .getHash("HEX");

@Caligatio
Copy link
Owner

Just released v3.3.0!

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