question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Method chaining when using `update`

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Caligatiocommented, Oct 10, 2022

Just released v3.3.0!

1reaction
Caligatiocommented, Oct 9, 2022

I got lazy and squelched the problematic eslint options 😃

This should be now implemented in 2c60363

Read more comments on GitHub >

github_iconTop Results From Across the Web

Method Chaining In Java with Examples - GeeksforGeeks
Method chaining in Java is a common syntax to invoke multiple methods calls in OOPs. Each method in chaining returns an object.
Read more >
Method chaining - why is it a good practice, or not?
IMO, the best way to use method chaining in this scenario is to create a parameter object to be passed to the function,...
Read more >
JavaScript Function Chaining - Medium
Function chaining is a pattern in JavaScript where multiple functions are called on the same object consecutively. Using the same object reference, ...
Read more >
The Unreasonable Effectiveness of Method Chaining in Pandas
One obvious advantage of Method chaining is that it is a top-down approach with arguments placed next to the function unlike the nested...
Read more >
Method Chaining in JavaScript - Tutorialspoint
In method chaining, we call separate methods of a single object like a chain without assigning the same object multiple times by assignment ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found