Changeset 29030

Show
Ignore:
Timestamp:
01/26/09 06:54:07 (4 years ago)
Author:
cho45
Message:

デフォルトのクロージャを使いまわすように

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

Legend:

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

    r29028 r29030  
    22// See http://coderepos.org/share/wiki/JSDeferred 
    33function Deferred(){return(this instanceof Deferred)? this.init():new Deferred()} 
    4 Deferred.prototype={ 
     4Deferred.ok=function(x){return x};Deferred.ng=function(x){throw x};Deferred.prototype={ 
    55init:function(){ 
    66this._next=null;this.callback={ 
    7 ok:function(x){return x}, 
    8 ng:function(x){throw x} 
     7ok:Deferred.ok, 
     8ng:Deferred.ng 
    99};return this;}, 
    1010next:function(fun){return this._post("ok",fun)}, 
  • lang/javascript/jsdeferred/trunk/jsdeferred.js

    r29028 r29030  
    8282 */ 
    8383function Deferred () { return (this instanceof Deferred) ? this.init() : new Deferred() } 
     84Deferred.ok = function (x) { return x }; 
     85Deferred.ng = function (x) { throw  x }; 
    8486Deferred.prototype = { 
    8587        init : function () { 
    8688                this._next    = null; 
    8789                this.callback = { 
    88                         ok: function (x) { return x }, 
    89                         ng: function (x) { throw  x } 
     90                        ok: Deferred.ok, 
     91                        ng: Deferred.ng 
    9092                }; 
    9193                return this; 
  • lang/javascript/jsdeferred/trunk/jsdeferred.mini.js

    r29028 r29030  
    22// See http://coderepos.org/share/wiki/JSDeferred 
    33function Deferred(){return(this instanceof Deferred)? this.init():new Deferred()} 
    4 Deferred.prototype={ 
     4Deferred.ok=function(x){return x};Deferred.ng=function(x){throw x};Deferred.prototype={ 
    55init:function(){ 
    66this._next=null;this.callback={ 
    7 ok:function(x){return x}, 
    8 ng:function(x){throw x} 
     7ok:Deferred.ok, 
     8ng:Deferred.ng 
    99};return this;}, 
    1010next:function(fun){return this._post("ok",fun)}, 
  • lang/javascript/jsdeferred/trunk/jsdeferred.nodoc.js

    r29028 r29030  
    22// See http://coderepos.org/share/wiki/JSDeferred 
    33function Deferred () { return (this instanceof Deferred) ? this.init() : new Deferred() } 
     4Deferred.ok = function (x) { return x }; 
     5Deferred.ng = function (x) { throw  x }; 
    46Deferred.prototype = { 
    57        init : function () { 
    68                this._next    = null; 
    79                this.callback = { 
    8                         ok: function (x) { return x }, 
    9                         ng: function (x) { throw  x } 
     10                        ok: Deferred.ok, 
     11                        ng: Deferred.ng 
    1012                }; 
    1113                return this; 
  • lang/javascript/jsdeferred/trunk/jsdeferred.userscript.js

    r29028 r29030  
    66 
    77function Deferred () { return (this instanceof Deferred) ? this.init() : new Deferred() } 
     8Deferred.ok = function (x) { return x }; 
     9Deferred.ng = function (x) { throw  x }; 
    810Deferred.prototype = { 
    911        init : function () { 
    1012                this._next    = null; 
    1113                this.callback = { 
    12                         ok: function (x) { return x }, 
    13                         ng: function (x) { throw  x } 
     14                        ok: Deferred.ok, 
     15                        ng: Deferred.ng 
    1416                }; 
    1517                return this;