Show
Ignore:
Timestamp:
12/08/07 23:34:20 (13 months ago)
Author:
cho45
Message:

lang/javascript/jsdeferred/trunk/jsdeferred.js:

next() が fun を省略できるように。
wait(0) の変わりにつかえるようにし、同期 -> 非同期への変換を簡単に

Location:
lang/javascript/jsdeferred/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/jsdeferred/trunk/jsdeferred.jquery.js

    r2820 r2889  
    3939clearTimeout(id);d.call((new Date).getTime()-t.getTime());},n*1000) 
    4040d.canceller=function(){try{clearTimeout(id)}catch(e){}};return d;};Deferred.next=function(fun){ 
    41 var d=new Deferred();var id=setTimeout(function(){clearTimeout(id);d.call()},0);d.callback.ok=fun;d.canceller=function(){try{clearTimeout(id)}catch(e){}};return d;};Deferred.call=function(f,args){ 
     41var d=new Deferred();var id=setTimeout(function(){clearTimeout(id);d.call()},0);if(fun)d.callback.ok=fun;d.canceller=function(){try{clearTimeout(id)}catch(e){}};return d;};Deferred.call=function(f,args){ 
    4242args=Array.prototype.slice.call(arguments);f=args.shift();return next(function(){ 
    4343return f.apply(this,args);});};Deferred.loop=function(n,fun){ 
  • lang/javascript/jsdeferred/trunk/jsdeferred.js

    r2820 r2889  
    156156                                if (--num <= 0) { 
    157157                                        if (dl instanceof Array) { 
    158                                                 // Object to Array 
    159158                                                values.length = dl.length; 
    160159                                                values = Array.prototype.slice.call(values, 0); 
     
    199198        var d = new Deferred(); 
    200199        var id = setTimeout(function () { clearTimeout(id); d.call() }, 0); 
    201         d.callback.ok = fun; 
     200        if (fun) d.callback.ok = fun; 
    202201        d.canceller   = function () { try { clearTimeout(id) } catch (e) {} }; 
    203202        return d; 
  • lang/javascript/jsdeferred/trunk/jsdeferred.mini.js

    r2820 r2889  
    3939clearTimeout(id);d.call((new Date).getTime()-t.getTime());},n*1000) 
    4040d.canceller=function(){try{clearTimeout(id)}catch(e){}};return d;};Deferred.next=function(fun){ 
    41 var d=new Deferred();var id=setTimeout(function(){clearTimeout(id);d.call()},0);d.callback.ok=fun;d.canceller=function(){try{clearTimeout(id)}catch(e){}};return d;};Deferred.call=function(f,args){ 
     41var d=new Deferred();var id=setTimeout(function(){clearTimeout(id);d.call()},0);if(fun)d.callback.ok=fun;d.canceller=function(){try{clearTimeout(id)}catch(e){}};return d;};Deferred.call=function(f,args){ 
    4242args=Array.prototype.slice.call(arguments);f=args.shift();return next(function(){ 
    4343return f.apply(this,args);});};Deferred.loop=function(n,fun){ 
  • lang/javascript/jsdeferred/trunk/jsdeferred.nodoc.js

    r2820 r2889  
    8181        var d = new Deferred(); 
    8282        var id = setTimeout(function () { clearTimeout(id); d.call() }, 0); 
    83         d.callback.ok = fun; 
     83        if (fun) d.callback.ok = fun; 
    8484        d.canceller   = function () { try { clearTimeout(id) } catch (e) {} }; 
    8585        return d; 
  • lang/javascript/jsdeferred/trunk/jsdeferred.userscript.js

    r2820 r2889  
    8585        var d = new Deferred(); 
    8686        var id = setTimeout(function () { clearTimeout(id); d.call() }, 0); 
    87         d.callback.ok = fun; 
     87        if (fun) d.callback.ok = fun; 
    8888        d.canceller   = function () { try { clearTimeout(id) } catch (e) {} }; 
    8989        return d;