How to track depth in a recursive callback?
<p>The code below is a recursive callback that takes an array that may contain more arrays.  How can I modify the code to know when it has completed running.  ParseBigToken will execute the callback.</p>

<p><strong>Notes</strong></p>

<p><code>isType()</code> - checks type.</p>

<p><code>buildCB()</code> - builds the callback function</p>

<p><code>appendResources()</code> - the the recusing function.</p>

<p><code>arr</code> - holds a multidimensional array</p>

<p><strong>Snippet</strong></p>

<pre><code>// ...snip

$P.isType = function (type, o) {
    return (Object.prototype.toString.call(o) === '[object ' + type + ']');
};
$P.buildCB = function (arr, kindex) {
    return function () {
        if (arr[kindex + 1] &amp;&amp; $P.isType('Array', arr[kindex + 1])) {
            $P.appendResources(arr[kindex + 1]);
        }
    };
};
$P.appendResources = function (arr) {
    var length,
        kindex;
    for (kindex = 0, length = arr.length; kindex &lt; length; kindex++) {
        if ($P.isType('String', arr[kindex])) {
            $P.parseBigToken(arr[kindex], $P.buildCB(arr, kindex));
        }
    }
};

// ... snip
</code></pre>

<p><strong>Example of arr</strong></p>

<pre><code>array:
    [
        'foo/source/foo.css',
        [
            'foo/source/foo.htm',
            'foo/source/foo.js',
        ]
    ]
</code></pre>
