Changeset 717

Show
Ignore:
Timestamp:
04/24/06 12:53:58 (2 years ago)
Author:
bob@redivi.com
Message:

rename find to findValue, forward to forwardCall

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mochikit/trunk/MochiKit/Async.js

    r662 r717  
    148148    }, 
    149149 
    150     toString: MochiKit.Base.forward("repr"), 
     150    toString: MochiKit.Base.forwardCall("repr"), 
    151151 
    152152    _nextId: MochiKit.Base.counter(), 
     
    624624        return 'DeferredLock(' + this.id + ', ' + state + ')'; 
    625625    }, 
    626     toString: MochiKit.Base.forward("repr") 
     626    toString: MochiKit.Base.forwardCall("repr") 
    627627 
    628628}; 
  • mochikit/trunk/MochiKit/Base.js

    r714 r717  
    277277    }, 
    278278 
    279     forward: function (func) { 
     279    forwardCall: function (func) { 
    280280        /*** 
    281281 
     
    10861086    }, 
    10871087 
    1088     find: function (lst, value, start/* = 0 */, /* optional */end) { 
     1088    findValue: function (lst, value, start/* = 0 */, /* optional */end) { 
    10891089        if (typeof(end) == "undefined" || end == null) { 
    10901090            end = lst.length; 
     
    12891289    "NamedError", 
    12901290    "operator", 
    1291     "forward", 
     1291    "forwardCall", 
    12921292    "itemgetter", 
    12931293    "typeMatcher", 
     
    13311331    "evalJSON", 
    13321332    "parseQueryString", 
    1333     "find", 
     1333    "findValue", 
    13341334    "findIdentical", 
    13351335    "flattenArguments" 
     
    13661366    // A singleton raised when no suitable adapter is found 
    13671367    var m = this; 
     1368 
     1369    // Backwards compat 
     1370    m.forward = m.forwardCall; 
     1371    m.find = m.findValue; 
     1372 
    13681373    if (typeof(encodeURIComponent) != "undefined") { 
    13691374        m.urlEncode = function (unencoded) { 
     
    13921397            } 
    13931398        }, 
    1394         toString: m.forward("repr") 
     1399        toString: m.forwardCall("repr") 
    13951400    }); 
    13961401 
  • mochikit/trunk/MochiKit/Iter.js

    r555 r717  
    126126        return { 
    127127            repr: function () { return "count(" + n + ")"; }, 
    128             toString: m.forward("repr"), 
     128            toString: m.forwardCall("repr"), 
    129129            next: m.counter(n) 
    130130        }; 
     
    143143        return { 
    144144            repr: function () { return "cycle(...)"; }, 
    145             toString: m.forward("repr"), 
     145            toString: m.forwardCall("repr"), 
    146146            next: function () { 
    147147                try { 
     
    183183                    return "repeat(" + m.repr(elem) + ")"; 
    184184                }, 
    185                 toString: m.forward("repr"), 
     185                toString: m.forwardCall("repr"), 
    186186                next: function () { 
    187187                    return elem; 
     
    193193                return "repeat(" + m.repr(elem) + ", " + n + ")"; 
    194194            }, 
    195             toString: m.forward("repr"), 
     195            toString: m.forwardCall("repr"), 
    196196            next: function () { 
    197197                if (n <= 0) { 
     
    224224        return { 
    225225            repr: function () { return "izip(...)"; }, 
    226             toString: m.forward("repr"), 
     226            toString: m.forwardCall("repr"), 
    227227            next: function () { return m.map(next, iterables); } 
    228228        }; 
     
    242242        return { 
    243243            repr: function () { return "ifilter(...)"; }, 
    244             toString: m.forward("repr"), 
     244            toString: m.forwardCall("repr"), 
    245245            next: function () { 
    246246                while (true) { 
     
    270270        return { 
    271271            repr: function () { return "ifilterfalse(...)"; }, 
    272             toString: m.forward("repr"), 
     272            toString: m.forwardCall("repr"), 
    273273            next: function () { 
    274274                while (true) { 
     
    312312                return "islice(" + ["...", start, stop, step].join(", ") + ")"; 
    313313            }, 
    314             toString: m.forward("repr"), 
     314            toString: m.forwardCall("repr"), 
    315315            next: function () { 
    316316                var rval; 
     
    341341        return { 
    342342            repr: function () { return "imap(...)"; }, 
    343             toString: m.forward("repr"), 
     343            toString: m.forwardCall("repr"), 
    344344            next: function () { 
    345345                return fun.apply(this, map(next, iterables)); 
     
    359359        return { 
    360360            repr: function () { return "applymap(...)"; }, 
    361             toString: m.forward("repr"), 
     361            toString: m.forwardCall("repr"), 
    362362            next: function () { 
    363363                return fun.apply(self, seq.next()); 
     
    381381        return { 
    382382            repr: function () { return "chain(...)"; }, 
    383             toString: m.forward("repr"), 
     383            toString: m.forwardCall("repr"), 
    384384            next: function () { 
    385385                while (argiter.length > 1) { 
     
    415415        return { 
    416416            repr: function () { return "takewhile(...)"; }, 
    417             toString: MochiKit.Base.forward("repr"), 
     417            toString: MochiKit.Base.forwardCall("repr"), 
    418418            next: function () { 
    419419                var rval = seq.next(); 
     
    441441        return { 
    442442            "repr": function () { return "dropwhile(...)"; }, 
    443             "toString": m.forward("repr"), 
     443            "toString": m.forwardCall("repr"), 
    444444            "next": function () { 
    445445                while (true) { 
     
    461461        return { 
    462462            repr: function () { return "tee(" + ident + ", ...)"; }, 
    463             toString: m.forward("repr"), 
     463            toString: m.forwardCall("repr"), 
    464464            next: function () { 
    465465                var rval; 
     
    639639                return "range(" + [start, stop, step].join(", ") + ")"; 
    640640            }, 
    641             toString: MochiKit.Base.forward("repr") 
     641            toString: MochiKit.Base.forwardCall("repr") 
    642642        }; 
    643643    }, 
     
    908908        return { 
    909909            repr: function () { return "arrayLikeIter(...)"; }, 
    910             toString: MochiKit.Base.forward("repr"), 
     910            toString: MochiKit.Base.forwardCall("repr"), 
    911911            next: function () { 
    912912                if (i >= iterable.length) { 
     
    925925        return { 
    926926            repr: function () { return "iterateNextIter(...)"; }, 
    927             toString: MochiKit.Base.forward("repr"), 
     927            toString: MochiKit.Base.forwardCall("repr"), 
    928928            next: function () { 
    929929                var rval = iterable.iterateNext(); 
  • mochikit/trunk/MochiKit/Logging.js

    r674 r717  
    7777            ).join(', ') + ')'; 
    7878    }, 
    79     toString: MochiKit.Base.forward("repr") 
     79    toString: MochiKit.Base.forwardCall("repr") 
    8080}; 
    8181 
  • mochikit/trunk/doc/html/MochiKit/Base.html

    r714 r717  
    459459</blockquote> 
    460460<p> 
    461 <a name="fn-find"></a> 
    462 <a class="mochidef reference" href="#fn-find">find(lst, value, start=0, end=lst.length)</a>:</p> 
     461<a name="fn-findvalue"></a> 
     462<a class="mochidef reference" href="#fn-findvalue">findValue(lst, value, start=0, end=lst.length)</a>:</p> 
    463463<blockquote> 
    464464<p>Finds the index of <tt class="docutils literal"><span class="pre">value</span></tt> in the <tt class="docutils literal"><span class="pre">Array</span></tt>-like object <tt class="docutils literal"><span class="pre">lst</span></tt> using 
     
    468468<p>For example:</p> 
    469469<pre class="literal-block"> 
    470 assert( find([1, 2, 3, 2, 1], 2) == 1 ) 
    471 assert( find([1, 2, 3, 2, 1], 2, 2) == 3 ) 
     470assert( findValue([1, 2, 3, 2, 1], 2) == 1 ) 
     471assert( findValue([1, 2, 3, 2, 1], 2, 2) == 3 ) 
    472472</pre> 
    473473</blockquote> 
     
    480480at the index <tt class="docutils literal"><span class="pre">end</span> <span class="pre">-</span> <span class="pre">1</span></tt>.  If <tt class="docutils literal"><span class="pre">value</span></tt> is not found in <tt class="docutils literal"><span class="pre">lst</span></tt>, it will 
    481481return <tt class="docutils literal"><span class="pre">-1</span></tt>.</p> 
    482 <p>You should use this function instead of <a class="mochiref reference" href="#fn-find">find</a> if <tt class="docutils literal"><span class="pre">lst</span></tt> may 
     482<p>You should use this function instead of <a class="mochiref reference" href="#fn-findvalue">findValue</a> if <tt class="docutils literal"><span class="pre">lst</span></tt> may 
    483483be comprised of objects for which no comparator is defined and all you care 
    484484about is finding an identical object (e.g. the same instance), or if 
     
    503503</blockquote> 
    504504<p> 
    505 <a name="fn-forward"></a> 
    506 <a class="mochidef reference" href="#fn-forward">forward(name)</a>:</p> 
     505<a name="fn-forwardcall"></a> 
     506<a class="mochidef reference" href="#fn-forwardcall">forwardCall(name)</a>:</p> 
    507507<blockquote> 
    508508Returns a function that forwards a method call to <tt class="docutils literal"><span class="pre">this.name(...)</span></tt></blockquote> 
  • mochikit/trunk/doc/html/MochiKit/VersionHistory.html

    r714 r717  
    1616<p>2006-04-XX      v1.3 &quot;warp zone&quot;</p> 
    1717<ul class="simple"> 
     18<li>IMPORTANT: Renamed MochiKit.Base.forward to forwardCall (for export)</li> 
     19<li>IMPORTANT: Renamed MochiKit.Base.find to findValue (for export)</li> 
    1820<li>New MochiKit.Base.flattenArguments for flattening a list of arguments to 
    1921a single Array</li> 
  • mochikit/trunk/doc/html/MochiKit/index.html

    r714 r717  
    5555<p>2006-04-XX      v1.3 &quot;warp zone&quot;</p> 
    5656<ul class="simple"> 
     57<li>IMPORTANT: Renamed MochiKit.Base.forward to forwardCall (for export)</li> 
     58<li>IMPORTANT: Renamed MochiKit.Base.find to findValue (for export)</li> 
    5759<li>New MochiKit.Base.flattenArguments for flattening a list of arguments to 
    5860a single Array</li> 
  • mochikit/trunk/doc/rst/MochiKit/Base.rst

    r714 r717  
    474474 
    475475 
    476 :mochidef:`find(lst, value, start=0, end=lst.length)`: 
     476:mochidef:`findValue(lst, value, start=0, end=lst.length)`: 
    477477 
    478478    Finds the index of ``value`` in the ``Array``-like object ``lst`` using 
     
    483483    For example:: 
    484484     
    485         assert( find([1, 2, 3, 2, 1], 2) == 1 ) 
    486         assert( find([1, 2, 3, 2, 1], 2, 2) == 3 ) 
     485        assert( findValue([1, 2, 3, 2, 1], 2) == 1 ) 
     486        assert( findValue([1, 2, 3, 2, 1], 2, 2) == 3 ) 
    487487 
    488488 
     
    494494    return ``-1``. 
    495495     
    496     You should use this function instead of :mochiref:`find` if ``lst`` may 
     496    You should use this function instead of :mochiref:`findValue` if ``lst`` may 
    497497    be comprised of objects for which no comparator is defined and all you care 
    498498    about is finding an identical object (e.g. the same instance), or if 
     
    515515 
    516516 
    517 :mochidef:`forward(name)`: 
     517:mochidef:`forwardCall(name)`: 
    518518 
    519519    Returns a function that forwards a method call to ``this.name(...)`` 
  • mochikit/trunk/doc/rst/MochiKit/VersionHistory.rst

    r714 r717  
    112006-04-XX      v1.3 "warp zone" 
    22 
     3- IMPORTANT: Renamed MochiKit.Base.forward to forwardCall (for export) 
     4- IMPORTANT: Renamed MochiKit.Base.find to findValue (for export) 
    35- New MochiKit.Base.flattenArguments for flattening a list of arguments to 
    46  a single Array 
  • mochikit/trunk/packed/MochiKit/MochiKit.js

    r714 r717  
    207207},contains:function(a,b){ 
    208208return b in a; 
    209 }},forward:function(_30){ 
     209}},forwardCall:function(_30){ 
    210210return function(){ 
    211211return this[_30].apply(this,arguments); 
     
    689689} 
    690690return -1; 
    691 },find:function(lst,_101,_102,end){ 
     691},findValue:function(lst,_101,_102,end){ 
    692692if(typeof (end)=="undefined"||end==null){ 
    693693end=lst.length; 
     
    810810return false; 
    811811}}; 
    812 MochiKit.Base.EXPORT=["counter","clone","extend","update","updatetree","setdefault","keys","items","NamedError","operator","forward","itemgetter","typeMatcher","isCallable","isUndefined","isUndefinedOrNull","isNull","isNotEmpty","isArrayLike","isDateLike","xmap","map","xfilter","filter","bind","bindMethods","NotFound","AdapterRegistry","registerComparator","compare","registerRepr","repr","objEqual","arrayEqual","concat","keyComparator","reverseKeyComparator","partial","merge","listMinMax","listMax","listMin","objMax","objMin","nodeWalk","zip","urlEncode","queryString","serializeJSON","registerJSON","evalJSON","parseQueryString","find","findIdentical","flattenArguments"]; 
     812MochiKit.Base.EXPORT=["counter","clone","extend","update","updatetree","setdefault","keys","items","NamedError","operator","forwardCall","itemgetter","typeMatcher","isCallable","isUndefined","isUndefinedOrNull","isNull","isNotEmpty","isArrayLike","isDateLike","xmap","map","xfilter","filter","bind","bindMethods","NotFound","AdapterRegistry","registerComparator","compare","registerRepr","repr","objEqual","arrayEqual","concat","keyComparator","reverseKeyComparator","partial","merge","listMinMax","listMax","listMin","objMax","objMin","nodeWalk","zip","urlEncode","queryString","serializeJSON","registerJSON","evalJSON","parseQueryString","findValue","findIdentical","flattenArguments"]; 
    813813MochiKit.Base.EXPORT_OK=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"]; 
    814814MochiKit.Base._exportSymbols=function(_124,_125){ 
     
    826826MochiKit.Base.__new__=function(){ 
    827827var m=this; 
     828m.forward=m.forwardCall; 
     829m.find=m.findValue; 
    828830if(typeof (encodeURIComponent)!="undefined"){ 
    829831m.urlEncode=function(_127){ 
     
    846848return this.name+"()"; 
    847849} 
    848 },toString:m.forward("repr")}); 
     850},toString:m.forwardCall("repr")}); 
    849851m.NotFound=new m.NamedError("MochiKit.Base.NotFound"); 
    850852m.listMax=m.partial(m.listMinMax,1); 
     
    926928return {repr:function(){ 
    927929return "count("+n+")"; 
    928 },toString:m.forward("repr"),next:m.counter(n)}; 
     930},toString:m.forwardCall("repr"),next:m.counter(n)}; 
    929931},cycle:function(p){ 
    930932var self=MochiKit.Iter; 
     
    934936return {repr:function(){ 
    935937return "cycle(...)"; 
    936 },toString:m.forward("repr"),next:function(){ 
     938},toString:m.forwardCall("repr"),next:function(){ 
    937939try{ 
    938940var rval=_136.next(); 
     
    963965return {repr:function(){ 
    964966return "repeat("+m.repr(elem)+")"; 
    965 },toString:m.forward("repr"),next:function(){ 
     967},toString:m.forwardCall("repr"),next:function(){ 
    966968return elem; 
    967969}}; 
     
    969971return {repr:function(){ 
    970972return "repeat("+m.repr(elem)+", "+n+")"; 
    971 },toString:m.forward("repr"),next:function(){ 
     973},toString:m.forwardCall("repr"),next:function(){ 
    972974if(n<=0){ 
    973975throw MochiKit.Iter.StopIteration; 
     
    984986return {repr:function(){ 
    985987return "izip(...)"; 
    986 },toString:m.forward("repr"),next:function(){ 
     988},toString:m.forwardCall("repr"),next:function(){ 
    987989return m.map(next,_141); 
    988990}}; 
     
    995997return {repr:function(){ 
    996998return "ifilter(...)"; 
    997 },toString:m.forward("repr"),next:function(){ 
     999},toString:m.forwardCall("repr"),next:function(){ 
    9981000while(true){ 
    9991001var rval=seq.next(); 
     
    10121014return {repr:function(){ 
    10131015return "ifilterfalse(...)"; 
    1014 },toString:m.forward("repr"),next:function(){ 
     1016},toString:m.forwardCall("repr"),next:function(){ 
    10151017while(true){ 
    10161018var rval=seq.next(); 
     
    10431045return {repr:function(){ 
    10441046return "islice("+["...",_144,stop,step].join(", ")+")"; 
    1045 },toString:m.forward("repr"),next:function(){ 
     1047},toString:m.forwardCall("repr"),next:function(){ 
    10461048var rval; 
    10471049while(i<_144){ 
     
    10631065return {repr:function(){ 
    10641066return "imap(...)"; 
    1065 },toString:m.forward("repr"),next:function(){ 
     1067},toString:m.forwardCall("repr"),next:function(){ 
    10661068return fun.apply(this,map(next,_148)); 
    10671069}}; 
     
    10711073return {repr:function(){ 
    10721074return "applymap(...)"; 
    1073 },toString:m.forward("repr"),next:function(){ 
     1075},toString:m.forwardCall("repr"),next:function(){ 
    10741076return fun.apply(self,seq.next()); 
    10751077}}; 
     
    10831085return {repr:function(){ 
    10841086return "chain(...)"; 
    1085 },toString:m.forward("repr"),next:function(){ 
     1087},toString:m.forwardCall("repr"),next:function(){ 
    10861088while(_150.length>1){ 
    10871089try{ 
     
    11071109return {repr:function(){ 
    11081110return "takewhile(...)"; 
    1109 },toString:MochiKit.Base.forward("repr"),next:function(){ 
     1111},toString:MochiKit.Base.forwardCall("repr"),next:function(){ 
    11101112var rval=seq.next(); 
    11111113if(!pred(rval)){ 
     
    11231125return {"repr":function(){ 
    11241126return "dropwhile(...)"; 
    1125 },"toString":m.forward("repr"),"next":function(){ 
     1127},"toString":m.forwardCall("repr"),"next":function(){ 
    11261128while(true){ 
    11271129var rval=seq.next(); 
     
    11391141return {repr:function(){ 
    11401142return "tee("+_152+", ...)"; 
    1141 },toString:m.forward("repr"),next:function(){ 
     1143},toString:m.forwardCall("repr"),next:function(){ 
    11421144var rval; 
    11431145var i=sync.pos[_152]; 
     
    12541256},repr:function(){ 
    12551257return "range("+[_162,stop,step].join(", ")+")"; 
    1256 },toString:MochiKit.Base.forward("repr")}; 
     1258},toString:MochiKit.Base.forwardCall("repr")}; 
    12571259},sum:function(_163,_164){ 
    12581260var x=_164||0; 
     
    14331435return {repr:function(){ 
    14341436return "arrayLikeIter(...)"; 
    1435 },toString:MochiKit.Base.forward("repr"),next:function(){ 
     1437},toString:MochiKit.Base.forwardCall("repr"),next:function(){ 
    14361438if(i>=_185.length){ 
    14371439throw MochiKit.Iter.StopIteration; 
     
    14441446return {repr:function(){ 
    14451447return "iterateNextIter(...)"; 
    1446 },toString:MochiKit.Base.forward("repr"),next:function(){ 
     1448},toString:MochiKit.Base.forwardCall("repr"),next:function(){ 
    14471449var rval=_187.iterateNext(); 
    14481450if(rval===null||rval===undefined){ 
     
    15031505var m=MochiKit.Base; 
    15041506return "LogMessage("+m.map(m.repr,[this.num,this.level,this.info]).join(", ")+")"; 
    1505 },toString:MochiKit.Base.forward("repr")}; 
     1507},toString:MochiKit.Base.forwardCall("repr")}; 
    15061508MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_191){ 
    15071509var self=MochiKit.Logging; 
     
    20722074} 
    20732075return "Deferred("+this.id+", "+_278+")"; 
    2074 },toString:MochiKit.Base.forward("repr"),_nextId:MochiKit.Base.counter(),cancel:function(){ 
     2076},toString:MochiKit.Base.forwardCall("repr"),_nextId:MochiKit.Base.counter(),cancel:function(){ 
    20752077var self=MochiKit.Async; 
    20762078if(this.fired==-1){ 
     
    23612363} 
    23622364return "DeferredLock("+this.id+", "+_300+")"; 
    2363 },toString:MochiKit.Base.forward("repr")}; 
     2365},toString:MochiKit.Base.forwardCall("repr")}; 
    23642366MochiKit.Async.DeferredList=function(list,_302,_303,_304,_305){ 
    23652367this.list=list; 
  • mochikit/trunk/tests/test_Base.js

    r714 r717  
    377377    t.is( c(), 3, "counter increases" ); 
    378378 
    379     t.is( find([1, 2, 3], 4), -1, "find returns -1 on not found"); 
    380     t.is( find([1, 2, 3], 1), 0, "find returns correct index"); 
    381     t.is( find([1, 2, 3], 1, 1), -1, "find honors start"); 
    382     t.is( find([1, 2, 3], 2, 0, 1), -1, "find honors end"); 
     379    t.is( findValue([1, 2, 3], 4), -1, "findValue returns -1 on not found"); 
     380    t.is( findValue([1, 2, 3], 1), 0, "findValue returns correct index"); 
     381    t.is( findValue([1, 2, 3], 1, 1), -1, "findValue honors start"); 
     382    t.is( findValue([1, 2, 3], 2, 0, 1), -1, "findValue honors end"); 
    383383    t.is( findIdentical([1, 2, 3], 4), -1, "findIdentical returns -1"); 
    384384    t.is( findIdentical([1, 2, 3], 1), 0, "findIdentical returns correct index");