No debounce within require.js module

Demonstration of how a require.js module has trouble working with an underscore debounce event.

by lddubeau

HTML

<script src="http://requirejs.org/docs/release/2.1.9/minified/require.js"></script>

JavaScript

require.config({
    paths: {
        'jquery': 'http://code.jquery.com/jquery-1.10.1.min',
        'underscore': '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min'
    },
    shim: {
        underscore: { exports: "_" }
    }
});

require(['jquery', 'underscore'], function ($, _) {
    var flyStat = {
        pct: -1,
        delay: 0,
        timeout: null,
        
        rnd: function (i) {
            flyStat.pct = Math.random() * 100.0;
            flyStat.trns(i);
        },
        trns: function (i) {
            console.log("TRNS[" + i + "]: " + flyStat.pct);
        },
        rpt: function () {
            console.log("RPT: " + flyStat.pct);
        },
    };

    flyStat.rtpd = _.debounce(flyStat.rpt, 1000);

    for (var i = 0; i < 1000; i++) {
        flyStat.rnd(i);
        flyStat.rtpd();
    }
});