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

Control flow functions are missing #382

Open
taxibutler opened this issue Jul 28, 2017 · 1 comment
Open

Control flow functions are missing #382

taxibutler opened this issue Jul 28, 2017 · 1 comment

Comments

@taxibutler
Copy link

taxibutler commented Jul 28, 2017

I find this library to be very difficult to use without control flow functions. This is absolutely unacceptable and should be remedied ASAP!!!

Below are a few examples how these would work:

five.times(function(){});
Executes the function passed as parameter five times.

five.moreTimes(function(){});
In case you need the function to be executed five more times, duh!

five.equals(some_variable_that_isnt_five).then(function(){}).else(function(){});
This is pretty self explanatory, I don't even know how you haven't thought about it yet!

@ConorOBrien-Foxx
Copy link

five.times = function times(func) {
    var smallFive = five() / five();
    while(smallFive !== five()) {
        func();
        smallFive++;
    }
}

five.moreTimes = function moreTimes(func) {
    five.times(func);
    five.times(func);
}

five.equals = function equals(possibleFive) {
    var fiveObject = {}; // sorry it's not a five
    
    fiveObject[five()] = five(); // here's my apology
    
    var isFive = possibleFive == five();
    
    var functor = function(failOrSucceed) {
        return function (todo) {
            if(failOrSucceed == isFive) {
                todo();
            }
            return fiveObject;
        }
    }
    
    fiveObject["then"] = functor(true);
    fiveObject["else"] = functor(false);
    
    return fiveObject;
}

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

1 participant