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.

Is there an alternative to baconjs’s function groupBy also in kefir available? If not, would it be accepted as PR?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
mAAdhaTTahcommented, Mar 31, 2020

The use of Kefir.later means that the value is being emitted after the test ends. Either use Kefir.constant, which will emit the value immediately, or use toEmitInTime and tick to advance the clock & emit that value.

1reaction
niecorecommented, Mar 28, 2020

If someone is looking for the solution:

const T = require("transducers-js");
const Kefir = require("kefir");

const groupBy = (keyF, limitF) => src => {
    const streams = {};

    return src.transduce(T.comp(
        T.filter((x) => !streams[keyF(x)]),
        T.map(function(firstValue) {
            const key = keyF(firstValue);
            const similarValues = src.changes().filter(x => keyF(x) === key );
            const data  = Kefir.later(0, firstValue).concat(similarValues);

            const limited = limitF(data, firstValue).withHandler((emitter, event) => {

                if (event.type === 'end') {
                    delete streams[key];
                    emitter.end();
                } else {
                    emitter.emit(event.value);
                }
            });

            streams[key] = limited;
            return limited;
        })
))};
Read more comments on GitHub >

github_iconTop Results From Across the Web

pandas.DataFrame.groupby — pandas 1.5.2 documentation
A groupby operation involves some combination of splitting the object, applying a function, and combining the results. This can be used to group...
Read more >
Pandas groupby() Explained With Examples
Similar to the SQL GROUP BY clause pandas DataFrame.groupby() function is used to collect identical data into groups and perform aggregate functions on....
Read more >
SQL GROUP BY Statement - W3Schools
The GROUP BY statement is often used with aggregate functions ( COUNT() , MAX() , MIN() , SUM() , AVG() ) to group...
Read more >
pandas GroupBy: Your Guide to Grouping Data in Python
You call .groupby() and pass the name of the column that you want to group on, which is "state" . Then, you use ......
Read more >
Pandas DataFrame: groupby() function - w3resource
The groupby() function is used to group DataFrame or Series using a mapper or by a Series of columns. A groupby operation involves...
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