jsSHA icon indicating copy to clipboard operation
jsSHA copied to clipboard

Method chaining when using `update`

Open ADTC opened this issue 3 years ago • 0 comments

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.

ADTC avatar Sep 20 '22 06:09 ADTC