I have a lot of functions that currently look like this:

function LoadFromURL(url) 
{
    var d = $.Deferred();
    $.get(url).then(function(text)
    {
        LoadFromText(text).then(function(obj)
        {
            d.resolve(obj);
        }, 
        function(err)
        {
            d.reject(err);
        });
    }, 
    function(err)
    {
        d.reject(err);
    });
    return d.promise();
}


This function takes a URL and loads the text within a promise. The text is then passed to the LoadFromText function which returns another promise. If this succeeds, the outer deferred is resolved. If the URL cannot be loaded, or the LoadFromText function fails then the outer deferred is rejected.

Is there a way that I can chain the result of the resolve / reject and end up with something like this:

function LoadFromURL(url) 
{
    return $.get(url).then(function(text)
    {
        return LoadFromText(text);
    }, 
    function(err)
    {
        return $.Deferred().reject(err);
    }).promise();
}


I've seen some implementations of promises that allow this - returning a promise within 'then', means that the eventual result of the promise is used. 

I realise this doesn't work at the moment (the result is the promise, rather than the result of the promise), but hopefully someone can suggest a way to make this work so I can tidy up the sometimes confusing mess of the first example.

I hope this makes sense. Thanks.


Question: Sneak attack advancement feat
Answer: Complete Adventurer had a prestige class for 3.5 called the daggerspell shaper, which advanced Sneak Attack, Spells, and Wild Shape. 

As for feats, I am not aware of any, but in the same vein as Daring Outlaw etc. from Complete Scoundrel, this feat seems quite reasonable:


  Natural Ambusher
  
  Requirements:
  
  
  Sneak Attack +2d6
  Trackless Step
  
  
  Benefit:
  
  Your druid levels stack with your rogue levels for the purposes of how much bonus damage you add on a Sneak Attack. For instance, a druid 4/rogue 3 with this feat would deal 4d6 extra damage on a Sneak Attack, as a rogue 7 would.
  
  Your rogue levels stack with your druid levels for the purposes of Nature Bond as well as your daily uses and options for Wild Shape. For example, a druid 4/rogue 3 with this feat could have an Animal Companion with the Devotion feature, and could use Wild Shape twice per day, since the druid&rsquo;s effective level would be 7 and these features are available at druid 6.