These are chat archives for ramda/ramda

11th
Dec 2017
functionalStoic
@functionalStoic
Dec 11 2017 20:53
Hello all. I’m working to replace a for loop (actually a pattern that shows up constantly in an app I am working on). The goal of these for loops is to find the various indexes of a certain value. Here’s an example:
function getFrameIndexFromName(frameName: string): number {
    for (var i = 0; i < FDWD.Frames.length; i++) {
        if (FDWD.Frames[i].wallpos !== undefined) {
            for (
                var j = 0;
                j < FDWD.Frames[i].wallpos.length;
                j++
            ) {
                if (FDWD.Frames[i].wallpos[j] === frameName) {
                    return i;
                }
            }
        }
    }
}
I used findIndex and it mostly works for what I need. I was just wondering if I might be missing any good uses of Ramda as I go through and refactor these
const result2 = R.findIndex(
    R.propEq('wallpos', [frameName]),
    FDWD.Frames
);