[Javascript] Jam shitty promise support forcefully into every last god damn function

Results 1 to 4 of 4
  1. #1
    Software Person TimeBomb is offline
    ModeratorRank
    May 2008 Join Date
    United StatesLocation
    1,252Posts

    [Javascript] Jam shitty promise support forcefully into every last god damn function

    Because fuck it.

    PHP Code:
    // NOTE TO HUMANITY: Don't use this code until humans have devolved to the point where we no longer have thumbs.

    Object.defineProperty(Function.prototype'promise', {
        
    get: function() {
            var 
    origFunc this;
            return function() {
                var 
    result origFunc.apply(thisarguments);
                return {
                    
    then: function then(callback) {
                        return 
    callback.promise(result);
                    },
                    
    done: function done(callback) {
                        return 
    callback(result);
                    }
                };
            };
        }
    }); 
    Example Usage:
    PHP Code:
    // NOTE TO APE HUMANITY: Here is a banana. https://imgur.com/gallery/z4T2iMJ

    var testFunc = function a(abc) { return a+b+c; };
    testFunc.promise 'abc';
    var 
    testFuncPromise testFunc.promise(1,1,2)
        .
    then(function c(result) {
            
    result += 1;
            
    console.log(result);
            return 
    result;
        })
        .
    then(function c(result) {
            
    result -= 1;
            
    console.log(result);
            return 
    result;
        })
        .
    done(function c(result) {
            
    result -= 1;
            
    console.log(result);
            return 
    result;
        })
    ;
    console.log('testFuncPromise: ' testFuncPromise);

    /* Outputs:
     * 5
     * 4
     * 3
     * testFuncPromise: 3
     */ 


  2. #2
    Alpha Member Caustik is offline
    MemberRank
    May 2011 Join Date
    LondonLocation
    1,837Posts

    Re: [Javascript] Jam shitty promise support forcefully into every last god damn funct


  3. #3
    • ♠️​ ♦️ ♣️ ​♥️ • שเ๒єtгเ๒є is offline
    MemberRank
    Mar 2012 Join Date
    917Posts

    Re: [Javascript] Jam shitty promise support forcefully into every last god damn funct


  4. #4
    • ♠️​ ♦️ ♣️ ​♥️ • שเ๒єtгเ๒є is offline
    MemberRank
    Mar 2012 Join Date
    917Posts

    Re: [Javascript] Jam shitty promise support forcefully into every last god damn funct

    I got another one haha




Advertisement