Changeset 720
- Timestamp:
- 04/24/06 13:21:43 (2 years ago)
- Files:
-
- mochikit/trunk/doc/html/MochiKit/Base.html (modified) (1 diff)
- mochikit/trunk/doc/html/MochiKit/VersionHistory.html (modified) (1 diff)
- mochikit/trunk/doc/html/MochiKit/index.html (modified) (1 diff)
- mochikit/trunk/packed/MochiKit/MochiKit.js (modified) (146 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mochikit/trunk/doc/html/MochiKit/Base.html
r717 r720 621 621 </blockquote> 622 622 <p> 623 <a name="fn-method"></a> 624 <a class="mochidef reference" href="#fn-method">method(self, func, ...)</a>:</p> 625 <blockquote> 626 <p>Alternate form of <a class="mochiref reference" href="#fn-bind">bind</a> that takes the object before the 627 function. These two are equivalent:</p> 628 <pre class="literal-block"> 629 bind("method", myobject) 630 method(myobject, "method") 631 </pre> 632 </blockquote> 633 <p> 623 634 <a name="fn-namefunctions"></a> 624 635 <a class="mochidef reference" href="#fn-namefunctions">nameFunctions(namespace)</a>:</p> mochikit/trunk/doc/html/MochiKit/VersionHistory.html
r717 r720 18 18 <li>IMPORTANT: Renamed MochiKit.Base.forward to forwardCall (for export)</li> 19 19 <li>IMPORTANT: Renamed MochiKit.Base.find to findValue (for export)</li> 20 <li>New MochiKit.Base.method as a convenience form of bind that takes the 21 object before the method</li> 20 22 <li>New MochiKit.Base.flattenArguments for flattening a list of arguments to 21 23 a single Array</li> mochikit/trunk/doc/html/MochiKit/index.html
r717 r720 57 57 <li>IMPORTANT: Renamed MochiKit.Base.forward to forwardCall (for export)</li> 58 58 <li>IMPORTANT: Renamed MochiKit.Base.find to findValue (for export)</li> 59 <li>New MochiKit.Base.method as a convenience form of bind that takes the 60 object before the method</li> 59 61 <li>New MochiKit.Base.flattenArguments for flattening a list of arguments to 60 62 a single Array</li> mochikit/trunk/packed/MochiKit/MochiKit.js
r717 r720 391 391 return eval("(func("+_47.join(",")+"))"); 392 392 }; 393 },bind:function(_48,_49){ 394 if(typeof (_48)=="string"){ 395 _48=_49[_48]; 396 } 397 var _50=_48.im_func; 398 var _51=_48.im_preargs; 399 var _52=_48.im_self; 393 },method:function(_48,_49){ 400 394 var m=MochiKit.Base; 401 if(typeof (_48)=="function"&&typeof (_48.apply)=="undefined"){ 402 _48=m._wrapDumbFunction(_48); 403 } 404 if(typeof (_50)!="function"){ 405 _50=_48; 406 } 407 if(typeof (_49)!="undefined"){ 408 _52=_49; 409 } 410 if(typeof (_51)=="undefined"){ 411 _51=[]; 412 }else{ 413 _51=_51.slice(); 414 } 415 m.extend(_51,arguments,2); 416 var _53=function(){ 417 var _54=arguments; 395 return m.bind.apply(this,m.extend([_49,_48],arguments,2)); 396 },bind:function(_50,_51){ 397 if(typeof (_50)=="string"){ 398 _50=_51[_50]; 399 } 400 var _52=_50.im_func; 401 var _53=_50.im_preargs; 402 var _54=_50.im_self; 403 var m=MochiKit.Base; 404 if(typeof (_50)=="function"&&typeof (_50.apply)=="undefined"){ 405 _50=m._wrapDumbFunction(_50); 406 } 407 if(typeof (_52)!="function"){ 408 _52=_50; 409 } 410 if(typeof (_51)!="undefined"){ 411 _54=_51; 412 } 413 if(typeof (_53)=="undefined"){ 414 _53=[]; 415 }else{ 416 _53=_53.slice(); 417 } 418 m.extend(_53,arguments,2); 419 var _55=function(){ 420 var _56=arguments; 418 421 var me=arguments.callee; 419 422 if(me.im_preargs.length>0){ 420 _5 4=m.concat(me.im_preargs,_54);421 } 422 var _ 49=me.im_self;423 if(!_ 49){424 _ 49=this;425 } 426 return me.im_func.apply(_ 49,_54);427 }; 428 _5 3.im_self=_52;429 _5 3.im_func=_50;430 _5 3.im_preargs=_51;431 return _5 3;432 },bindMethods:function(_5 5){433 var _5 6=MochiKit.Base.bind;434 for(var k in _5 5){435 var _5 7=_55[k];436 if(typeof (_5 7)=="function"){437 _5 5[k]=_56(_57,_55);438 } 439 } 440 },registerComparator:function(_ 58,_59,_60,_61){441 MochiKit.Base.comparatorRegistry.register(_ 58,_59,_60,_61);423 _56=m.concat(me.im_preargs,_56); 424 } 425 var _51=me.im_self; 426 if(!_51){ 427 _51=this; 428 } 429 return me.im_func.apply(_51,_56); 430 }; 431 _55.im_self=_54; 432 _55.im_func=_52; 433 _55.im_preargs=_53; 434 return _55; 435 },bindMethods:function(_57){ 436 var _58=MochiKit.Base.bind; 437 for(var k in _57){ 438 var _59=_57[k]; 439 if(typeof (_59)=="function"){ 440 _57[k]=_58(_59,_57); 441 } 442 } 443 },registerComparator:function(_60,_61,_62,_63){ 444 MochiKit.Base.comparatorRegistry.register(_60,_61,_62,_63); 442 445 },_primitives:{"bool":true,"string":true,"number":true},compare:function(a,b){ 443 446 if(a==b){ 444 447 return 0; 445 448 } 446 var _6 2=(typeof (a)=="undefined"||a==null);447 var _6 3=(typeof (b)=="undefined"||b==null);448 if(_6 2&&_63){449 var _64=(typeof (a)=="undefined"||a==null); 450 var _65=(typeof (b)=="undefined"||b==null); 451 if(_64&&_65){ 449 452 return 0; 450 453 }else{ 451 if(_6 2){454 if(_64){ 452 455 return -1; 453 456 }else{ 454 if(_6 3){457 if(_65){ 455 458 return 1; 456 459 } … … 458 461 } 459 462 var m=MochiKit.Base; 460 var _6 4=m._primitives;461 if(!(typeof (a) in _6 4&&typeof (b) in _64)){463 var _66=m._primitives; 464 if(!(typeof (a) in _66&&typeof (b) in _66)){ 462 465 try{ 463 466 return m.comparatorRegistry.match(a,b); … … 476 479 } 477 480 } 478 var _6 5=m.repr;479 throw new TypeError(_6 5(a)+" and "+_65(b)+" can not be compared");481 var _67=m.repr; 482 throw new TypeError(_67(a)+" and "+_67(b)+" can not be compared"); 480 483 },compareDateLike:function(a,b){ 481 484 return MochiKit.Base.compare(a.getTime(),b.getTime()); 482 485 },compareArrayLike:function(a,b){ 483 var _6 6=MochiKit.Base.compare;484 var _6 7=a.length;485 var _ 68=0;486 if(_6 7>b.length){487 _ 68=1;488 _6 7=b.length;489 }else{ 490 if(_6 7<b.length){491 _ 68=-1;492 } 493 } 494 for(var i=0;i<_6 7;i++){495 var cmp=_6 6(a[i],b[i]);486 var _68=MochiKit.Base.compare; 487 var _69=a.length; 488 var _70=0; 489 if(_69>b.length){ 490 _70=1; 491 _69=b.length; 492 }else{ 493 if(_69<b.length){ 494 _70=-1; 495 } 496 } 497 for(var i=0;i<_69;i++){ 498 var cmp=_68(a[i],b[i]); 496 499 if(cmp){ 497 500 return cmp; 498 501 } 499 502 } 500 return _ 68;501 },registerRepr:function(_7 0,_71,_72,_73){502 MochiKit.Base.reprRegistry.register(_7 0,_71,_72,_73);503 return _70; 504 },registerRepr:function(_72,_73,_74,_75){ 505 MochiKit.Base.reprRegistry.register(_72,_73,_74,_75); 503 506 },repr:function(o){ 504 507 if(typeof (o)=="undefined"){ … … 525 528 } 526 529 try{ 527 var _7 4=(o+"");530 var _76=(o+""); 528 531 } 529 532 catch(e){ … … 531 534 } 532 535 if(typeof (o)=="function"){ 533 o=_7 4.replace(/^\s+/,"");536 o=_76.replace(/^\s+/,""); 534 537 var idx=o.indexOf("{"); 535 538 if(idx!=-1){ … … 537 540 } 538 541 } 539 return _7 4;542 return _76; 540 543 },reprArrayLike:function(o){ 541 544 var m=MochiKit.Base; … … 545 548 },reprNumber:function(o){ 546 549 return o+""; 547 },registerJSON:function(_7 6,_77,_78,_79){548 MochiKit.Base.jsonRegistry.register(_7 6,_77,_78,_79);550 },registerJSON:function(_78,_79,_80,_81){ 551 MochiKit.Base.jsonRegistry.register(_78,_79,_80,_81); 549 552 },evalJSON:function(){ 550 553 return eval("("+arguments[0]+")"); 551 554 },serializeJSON:function(o){ 552 var _8 0=typeof (o);553 if(_8 0=="undefined"){555 var _82=typeof (o); 556 if(_82=="undefined"){ 554 557 return "undefined"; 555 558 }else{ 556 if(_8 0=="number"||_80=="boolean"){559 if(_82=="number"||_82=="boolean"){ 557 560 return o+""; 558 561 }else{ … … 563 566 } 564 567 var m=MochiKit.Base; 565 var _8 1=m.reprString;566 if(_8 0=="string"){567 return _8 1(o);568 var _83=m.reprString; 569 if(_82=="string"){ 570 return _83(o); 568 571 } 569 572 var me=arguments.callee; 570 var _8 2;573 var _84; 571 574 if(typeof (o.__json__)=="function"){ 572 _8 2=o.__json__();573 if(o!==_8 2){574 return me(_8 2);575 _84=o.__json__(); 576 if(o!==_84){ 577 return me(_84); 575 578 } 576 579 } 577 580 if(typeof (o.json)=="function"){ 578 _8 2=o.json();579 if(o!==_8 2){580 return me(_8 2);581 } 582 } 583 if(_8 0!="function"&&typeof (o.length)=="number"){581 _84=o.json(); 582 if(o!==_84){ 583 return me(_84); 584 } 585 } 586 if(_82!="function"&&typeof (o.length)=="number"){ 584 587 var res=[]; 585 588 for(var i=0;i<o.length;i++){ … … 593 596 } 594 597 try{ 595 _8 2=m.jsonRegistry.match(o);596 return me(_8 2);598 _84=m.jsonRegistry.match(o); 599 return me(_84); 597 600 } 598 601 catch(e){ … … 601 604 } 602 605 } 603 if(_8 0=="function"){606 if(_82=="function"){ 604 607 return null; 605 608 } 606 609 res=[]; 607 610 for(var k in o){ 608 var _8 4;611 var _86; 609 612 if(typeof (k)=="number"){ 610 _8 4="\""+k+"\"";613 _86="\""+k+"\""; 611 614 }else{ 612 615 if(typeof (k)=="string"){ 613 _8 4=_81(k);616 _86=_83(k); 614 617 }else{ 615 618 continue; … … 620 623 continue; 621 624 } 622 res.push(_8 4+":"+val);625 res.push(_86+":"+val); 623 626 } 624 627 return "{"+res.join(", ")+"}"; 625 628 },objEqual:function(a,b){ 626 629 return (MochiKit.Base.compare(a,b)==0); 627 },arrayEqual:function(_8 5,arr){628 if(_8 5.length!=arr.length){630 },arrayEqual:function(_87,arr){ 631 if(_87.length!=arr.length){ 629 632 return false; 630 633 } 631 return (MochiKit.Base.compare(_8 5,arr)==0);634 return (MochiKit.Base.compare(_87,arr)==0); 632 635 },concat:function(){ 633 var _8 7=[];634 var _ 88=MochiKit.Base.extend;636 var _89=[]; 637 var _90=MochiKit.Base.extend; 635 638 for(var i=0;i<arguments.length;i++){ 636 _ 88(_87,arguments[i]);637 } 638 return _8 7;639 _90(_89,arguments[i]); 640 } 641 return _89; 639 642 },keyComparator:function(key){ 640 643 var m=MochiKit.Base; 641 var _9 0=m.compare;644 var _92=m.compare; 642 645 if(arguments.length==1){ 643 646 return function(a,b){ 644 return _9 0(a[key],b[key]);645 }; 646 } 647 var _9 1=m.extend(null,arguments);647 return _92(a[key],b[key]); 648 }; 649 } 650 var _93=m.extend(null,arguments); 648 651 return function(a,b){ 649 var _9 2=0;650 for(var i=0;(_9 2==0)&&(i<_91.length);i++){651 var key=_9 1[i];652 _9 2=_90(a[key],b[key]);653 } 654 return _9 2;652 var _94=0; 653 for(var i=0;(_94==0)&&(i<_93.length);i++){ 654 var key=_93[i]; 655 _94=_92(a[key],b[key]); 656 } 657 return _94; 655 658 }; 656 659 },reverseKeyComparator:function(key){ 657 var _9 3=MochiKit.Base.keyComparator.apply(this,arguments);660 var _95=MochiKit.Base.keyComparator.apply(this,arguments); 658 661 return function(a,b){ 659 return _9 3(b,a);660 }; 661 },partial:function(_9 4){662 return _95(b,a); 663 }; 664 },partial:function(_96){ 662 665 var m=MochiKit.Base; 663 return m.bind.apply(this,m.extend([_9 4,undefined],arguments,1));664 },listMinMax:function(_9 5,lst){666 return m.bind.apply(this,m.extend([_96,undefined],arguments,1)); 667 },listMinMax:function(_97,lst){ 665 668 if(lst.length==0){ 666 669 return null; 667 670 } 668 671 var cur=lst[0]; 669 var _9 7=MochiKit.Base.compare;672 var _99=MochiKit.Base.compare; 670 673 for(var i=1;i<lst.length;i++){ 671 674 var o=lst[i]; 672 if(_9 7(o,cur)==_95){675 if(_99(o,cur)==_97){ 673 676 cur=o; 674 677 } … … 679 682 },objMin:function(){ 680 683 return MochiKit.Base.listMinMax(-1,arguments); 681 },findIdentical:function(lst,_ 98,_99,end){684 },findIdentical:function(lst,_100,_101,end){ 682 685 if(typeof (end)=="undefined"||end==null){ 683 686 end=lst.length; 684 687 } 685 for(var i=(_ 99||0);i<end;i++){686 if(lst[i]===_ 98){688 for(var i=(_101||0);i<end;i++){ 689 if(lst[i]===_100){ 687 690 return i; 688 691 } 689 692 } 690 693 return -1; 691 },findValue:function(lst,_10 1,_102,end){694 },findValue:function(lst,_103,_104,end){ 692 695 if(typeof (end)=="undefined"||end==null){ 693 696 end=lst.length; 694 697 } 695 698 var cmp=MochiKit.Base.compare; 696 for(var i=(_10 2||0);i<end;i++){697 if(cmp(lst[i],_10 1)==0){699 for(var i=(_104||0);i<end;i++){ 700 if(cmp(lst[i],_103)==0){ 698 701 return i; 699 702 } 700 703 } 701 704 return -1; 702 },nodeWalk:function(node,_10 4){703 var _10 5=[node];704 var _10 6=MochiKit.Base.extend;705 while(_10 5.length){706 var res=_10 4(_105.shift());705 },nodeWalk:function(node,_106){ 706 var _107=[node]; 707 var _108=MochiKit.Base.extend; 708 while(_107.length){ 709 var res=_106(_107.shift()); 707 710 if(res){ 708 _10 6(_105,res);709 } 710 } 711 },nameFunctions:function(_10 7){712 var base=_10 7.NAME;711 _108(_107,res); 712 } 713 } 714 },nameFunctions:function(_109){ 715 var base=_109.NAME; 713 716 if(typeof (base)=="undefined"){ 714 717 base=""; … … 716 719 base=base+"."; 717 720 } 718 for(var name in _10 7){719 var o=_10 7[name];721 for(var name in _109){ 722 var o=_109[name]; 720 723 if(typeof (o)=="function"&&typeof (o.NAME)=="undefined"){ 721 724 try{ … … 726 729 } 727 730 } 728 },queryString:function(_11 0,_111){729 if(typeof (MochiKit.DOM)!="undefined"&&arguments.length==1&&(typeof (_11 0)=="string"||(typeof (_110.nodeType)!="undefined"&&_110.nodeType>0))){730 var kv=MochiKit.DOM.formContents(_11 0);731 _11 0=kv[0];732 _11 1=kv[1];731 },queryString:function(_112,_113){ 732 if(typeof (MochiKit.DOM)!="undefined"&&arguments.length==1&&(typeof (_112)=="string"||(typeof (_112.nodeType)!="undefined"&&_112.nodeType>0))){ 733 var kv=MochiKit.DOM.formContents(_112); 734 _112=kv[0]; 735 _113=kv[1]; 733 736 }else{ 734 737 if(arguments.length==1){ 735 var o=_11 0;736 _11 0=[];737 _11 1=[];738 var o=_112; 739 _112=[]; 740 _113=[]; 738 741 for(var k in o){ 739 742 var v=o[k]; 740 743 if(typeof (v)!="function"){ 741 _11 0.push(k);742 _11 1.push(v);744 _112.push(k); 745 _113.push(v); 743 746 } 744 747 } … … 746 749 } 747 750 var rval=[]; 748 var len=Math.min(_11 0.length,_111.length);749 var _11 5=MochiKit.Base.urlEncode;751 var len=Math.min(_112.length,_113.length); 752 var _117=MochiKit.Base.urlEncode; 750 753 for(var i=0;i<len;i++){ 751 v=_11 1[i];754 v=_113[i]; 752 755 if(typeof (v)!="undefined"&&v!=null){ 753 rval.push(_11 5(_110[i])+"="+_115(v));756 rval.push(_117(_112[i])+"="+_117(v)); 754 757 } 755 758 } 756 759 return rval.join("&"); 757 },parseQueryString:function(_11 6,_117){758 var _1 18=_116.replace(/\+/g,"%20").split("&");760 },parseQueryString:function(_118,_119){ 761 var _120=_118.replace(/\+/g,"%20").split("&"); 759 762 var o={}; 760 var _1 19;763 var _121; 761 764 if(typeof (decodeURIComponent)!="undefined"){ 762 _1 19=decodeURIComponent;763 }else{ 764 _1 19=unescape;765 } 766 if(_11 7){767 for(var i=0;i<_1 18.length;i++){768 var pair=_1 18[i].split("=");769 var name=_1 19(pair[0]);765 _121=decodeURIComponent; 766 }else{ 767 _121=unescape; 768 } 769 if(_119){ 770 for(var i=0;i<_120.length;i++){ 771 var pair=_120[i].split("="); 772 var name=_121(pair[0]); 770 773 var arr=o[name]; 771 774 if(!(arr instanceof Array)){ … … 773 776 o[name]=arr; 774 777 } 775 arr.push(_1 19(pair[1]));776 } 777 }else{ 778 for(i=0;i<_1 18.length;i++){779 pair=_1 18[i].split("=");780 o[_1 19(pair[0])]=_119(pair[1]);778 arr.push(_121(pair[1])); 779 } 780 }else{ 781 for(i=0;i<_120.length;i++){ 782 pair=_120[i].split("="); 783 o[_121(pair[0])]=_121(pair[1]); 781 784 } 782 785 } … … 786 789 this.pairs=[]; 787 790 }; 788 MochiKit.Base.AdapterRegistry.prototype={register:function(name,_12 1,wrap,_123){789 if(_12 3){790 this.pairs.unshift([name,_12 1,wrap]);791 }else{ 792 this.pairs.push([name,_12 1,wrap]);791 MochiKit.Base.AdapterRegistry.prototype={register:function(name,_123,wrap,_125){ 792 if(_125){ 793 this.pairs.unshift([name,_123,wrap]); 794 }else{ 795 this.pairs.push([name,_123,wrap]); 793 796 } 794 797 },match:function(){ … … 810 813 return false; 811 814 }}; 812 MochiKit.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" ];815 MochiKit.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","method"]; 813 816 MochiKit.Base.EXPORT_OK=["nameFunctions","comparatorRegistry","reprRegistry","jsonRegistry","compareDateLike","compareArrayLike","reprArrayLike","reprString","reprNumber"]; 814 MochiKit.Base._exportSymbols=function(_12 4,_125){817 MochiKit.Base._exportSymbols=function(_126,_127){ 815 818 if(typeof (MochiKit.__export__)=="undefined"){ 816 819 MochiKit.__export__=(MochiKit.__compat__||(typeof (JSAN)=="undefined"&&typeof (dojo)=="undefined")); … … 819 822 return; 820 823 } 821 var all=_12 5.EXPORT_TAGS[":all"];824 var all=_127.EXPORT_TAGS[":all"]; 822 825 for(var i=0;i<all.length;i++){ 823 _12 4[all[i]]=_125[all[i]];826 _126[all[i]]=_127[all[i]]; 824 827 } 825 828 }; … … 829 832 m.find=m.findValue; 830 833 if(typeof (encodeURIComponent)!="undefined"){ 831 m.urlEncode=function(_12 7){832 return encodeURIComponent(_12 7).replace(/\'/g,"%27");833 }; 834 }else{ 835 m.urlEncode=function(_1 28){836 return escape(_1 28).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval.replace(/\'/g,"%27");834 m.urlEncode=function(_129){ 835 return encodeURIComponent(_129).replace(/\'/g,"%27"); 836 }; 837 }else{ 838 m.urlEncode=function(_130){ 839 return escape(_130).replace(/\+/g,"%2B").replace(/\"/g,"%22").rval.replace(/\'/g,"%27"); 837 840 }; 838 841 } … … 895 898 },toString:function(){ 896 899 return this.__repr__(); 897 },registerIteratorFactory:function(name,_1 29,_130,_131){898 MochiKit.Iter.iteratorRegistry.register(name,_1 29,_130,_131);899 },iter:function(_13 2,_133){900 },registerIteratorFactory:function(name,_131,_132,_133){ 901 MochiKit.Iter.iteratorRegistry.register(name,_131,_132,_133); 902 },iter:function(_134,_135){ 900 903 var self=MochiKit.Iter; 901 904 if(arguments.length==2){ 902 905 return self.takewhile(function(a){ 903 return a!=_13 3;904 },_13 2);905 } 906 if(typeof (_13 2.next)=="function"){907 return _13 2;908 }else{ 909 if(typeof (_13 2.iter)=="function"){910 return _13 2.iter();911 } 912 } 913 try{ 914 return self.iteratorRegistry.match(_13 2);906 return a!=_135; 907 },_134); 908 } 909 if(typeof (_134.next)=="function"){ 910 return _134; 911 }else{ 912 if(typeof (_134.iter)=="function"){ 913 return _134.iter(); 914 } 915 } 916 try{ 917 return self.iteratorRegistry.match(_134); 915 918 } 916 919 catch(e){ 917 920 var m=MochiKit.Base; 918 921 if(e==m.NotFound){ 919 e=new TypeError(typeof (_13 2)+": "+m.repr(_132)+" is not iterable");922 e=new TypeError(typeof (_134)+": "+m.repr(_134)+" is not iterable"); 920 923 } 921 924 throw e; … … 933 936 var m=MochiKit.Base; 934 937 var lst=[]; 935 var _13 6=self.iter(p);938 var _138=self.iter(p); 936 939 return {repr:function(){ 937 940 return "cycle(...)"; 938 941 },toString:m.forwardCall("repr"),next:function(){ 939 942 try{ 940 var rval=_13 6.next();943 var rval=_138.next(); 941 944 lst.push(rval); 942 945 return rval; … … 978 981 return elem; 979 982 }}; 980 },next:function(_1 38){981 return _1 38.next();983 },next:function(_140){ 984 return _140.next(); 982 985 },izip:function(p,q){ 983 986 var m=MochiKit.Base; 984 987 var next=MochiKit.Iter.next; 985 var _14 1=m.map(iter,arguments);988 var _143=m.map(iter,arguments); 986 989 return {repr:function(){ 987 990 return "izip(...)"; 988 991 },toString:m.forwardCall("repr"),next:function(){ 989 return m.map(next,_14 1);992 return m.map(next,_143); 990 993 }}; 991 994 },ifilter:function(pred,seq){ … … 1027 1030 var m=MochiKit.Base; 1028 1031 seq=self.iter(seq); 1029 var _14 4=0;1032 var _146=0; 1030 1033 var stop=0; 1031 1034 var step=1; … … 1035 1038 }else{ 1036 1039 if(arguments.length==3){ 1037 _14 4=arguments[1];1040 _146=arguments[1]; 1038 1041 stop=arguments[2]; 1039 1042 }else{ 1040 _14 4=arguments[1];1043 _146=arguments[1]; 1041 1044 stop=arguments[2]; 1042 1045 step=arguments[3]; … … 1044 1047 } 1045 1048 return {repr:function(){ 1046 return "islice("+["...",_14 4,stop,step].join(", ")+")";1049 return "islice("+["...",_146,stop,step].join(", ")+")"; 1047 1050 },toString:m.forwardCall("repr"),next:function(){ 1048 1051 var rval; 1049 while(i<_14 4){1052 while(i<_146){ 1050 1053 rval=seq.next(); 1051 1054 i++; 1052 1055 } 1053 if(_14 4>=stop){1056 if(_146>=stop){ 1054 1057 throw self.StopIteration; 1055 1058 } 1056 _14 4+=step;1059 _146+=step; 1057 1060 return rval; 1058 1061 }}; … … 1060 1063 var m=MochiKit.Base; 1061 1064 var self=MochiKit.Iter; 1062 var _1 48=m.map(self.iter,m.extend(null,arguments,1));1065 var _150=m.map(self.iter,m.extend(null,arguments,1)); 1063 1066 var map=m.map; 1064 1067 var next=self.next; … … 1066 1069 return "imap(...)"; 1067 1070 },toString:m.forwardCall("repr"),next:function(){ 1068 return fun.apply(this,map(next,_1 48));1071 return fun.apply(this,map(next,_150)); 1069 1072 }}; 1070 1073 },applymap:function(fun,seq,self){ … … 1082 1085 return self.iter(arguments[0]); 1083 1086 } 1084 var _15 0=m.map(self.iter,arguments);1087 var _152=m.map(self.iter,arguments); 1085 1088 return {repr:function(){ 1086 1089 return "chain(...)"; 1087 1090 },toString:m.forwardCall("repr"),next:function(){ 1088 while(_15 0.length>1){1089 try{ 1090 return _15 0[0].next();1091 while(_152.length>1){ 1092 try{ 1093 return _152[0].next(); 1091 1094 } 1092 1095 catch(e){ … … 1094 1097 throw e; 1095 1098 } 1096 _15 0.shift();1097 } 1098 } 1099 if(_15 0.length==1){1100 var arg=_15 0.shift();1099 _152.shift(); 1100 } 1101 } 1102 if(_152.length==1){ 1103 var arg=_152.shift(); 1101 1104 this.next=m.bind("next",arg); 1102 1105 return this.next(); … … 1135 1138 return rval; 1136 1139 }}; 1137 },_tee:function(_15 2,sync,_154){1138 sync.pos[_15 2]=-1;1140 },_tee:function(_154,sync,_156){ 1141 sync.pos[_154]=-1; 1139 1142 var m=MochiKit.Base; 1140 var _15 5=m.listMin;1143 var _157=m.listMin; 1141 1144 return {repr:function(){ 1142 return "tee("+_15 2+", ...)";1145 return "tee("+_154+", ...)"; 1143 1146 },toString:m.forwardCall("repr"),next:function(){ 1144 1147 var rval; 1145 var i=sync.pos[_15 2];1148 var i=sync.pos[_154]; 1146 1149 if(i==sync.max){ 1147 rval=_15 4.next();1150 rval=_156.next(); 1148 1151 sync.deque.push(rval); 1149 1152 sync.max+=1; 1150 sync.pos[_15 2]+=1;1153 sync.pos[_154]+=1; 1151 1154 }else{ 1152 1155 rval=sync.deque[i-sync.min]; 1153 sync.pos[_15 2]+=1;1154 if(i==sync.min&&_15 5(sync.pos)!=sync.min){1156 sync.pos[_154]+=1; 1157 if(i==sync.min&&_157(sync.pos)!=sync.min){ 1155 1158 sync.min+=1; 1156 1159 sync.deque.shift(); … … 1159 1162 return rval; 1160 1163 }}; 1161 },tee:function(_15 6,n){1164 },tee:function(_158,n){ 1162 1165 var rval=[]; 1163 1166 var sync={"pos":[],"deque":[],"max":-1,"min":-1}; … … 1166 1169 } 1167 1170 var self=MochiKit.Iter; 1168 _15 6=self.iter(_156);1171 _158=self.iter(_158); 1169 1172 var _tee=self._tee; 1170 1173 for(var i=0;i<n;i++){ 1171 rval.push(_tee(i,sync,_15 6));1174 rval.push(_tee(i,sync,_158)); 1172 1175 } 1173 1176 return rval; 1174 },list:function(_1 58){1177 },list:function(_160){ 1175 1178 var m=MochiKit.Base; 1176 if(typeof (_1 58.slice)=="function"){1177 return _1 58.slice();1178 }else{ 1179 if(m.isArrayLike(_1 58)){1180 return m.concat(_1 58);1179 if(typeof (_160.slice)=="function"){ 1180 return _160.slice(); 1181 }else{ 1182 if(m.isArrayLike(_160)){ 1183 return m.concat(_160); 1181 1184 } 1182 1185 } 1183 1186 var self=MochiKit.Iter; 1184 _1 58=self.iter(_158);1187 _160=self.iter(_160); 1185 1188 var rval=[]; 1186 1189 try{ 1187 1190 while(true){ 1188 rval.push(_1 58.next());1191 rval.push(_160.next()); 1189 1192 } 1190 1193 } … … 1196 1199 } 1197 1200 return undefined; 1198 },reduce:function(fn,_1 59,_160){1201 },reduce:function(fn,_161,_162){ 1199 1202 var i=0; 1200 var x=_16 0;1203 var x=_162; 1201 1204 var self=MochiKit.Iter; 1202 _1 59=self.iter(_159);1205 _161=self.iter(_161); 1203 1206 if(arguments.length<3){ 1204 1207 try{ 1205 x=_1 59.next();1208 x=_161.next(); 1206 1209 } 1207 1210 catch(e){ … … 1215 1218 try{ 1216 1219 while(true){ 1217 x=fn(x,_1 59.next());1220 x=fn(x,_161.next()); 1218 1221 } 1219 1222 } … … 1225 1228 return x; 1226 1229 },range:function(){ 1227 var _16 2=0;1230 var _164=0; 1228 1231 var stop=0; 1229 1232 var step=1; … … 1232 1235 }else{ 1233 1236 if(arguments.length==2){ 1234 _16 2=arguments[0];1237 _164=arguments[0]; 1235 1238 stop=arguments[1]; 1236 1239 }else{ 1237 1240 if(arguments.length==3){ 1238 _16 2=arguments[0];1241 _164=arguments[0]; 1239 1242 stop=arguments[1]; 1240 1243 step=arguments[2]; … … 1248 1251 } 1249 1252 return {next:function(){ 1250 if((step>0&&_16 2>=stop)||(step<0&&_162<=stop)){1253 if((step>0&&_164>=stop)||(step<0&&_164<=stop)){ 1251 1254 throw MochiKit.Iter.StopIteration; 1252 1255 } 1253 var rval=_16 2;1254 _16 2+=step;1256 var rval=_164; 1257 _164+=step; 1255 1258 return rval; 1256 1259 },repr:function(){ 1257 return "range("+[_16 2,stop,step].join(", ")+")";1260 return "range("+[_164,stop,step].join(", ")+")"; 1258 1261 },toString:MochiKit.Base.forwardCall("repr")}; 1259 },sum:function(_16 3,_164){1260 var x=_16 4||0;1262 },sum:function(_165,_166){ 1263 var x=_166||0; 1261 1264 var self=MochiKit.Iter; 1262 _16 3=self.iter(_163);1265 _165=self.iter(_165); 1263 1266 try{ 1264 1267 while(true){ 1265 x+=_16 3.next();1268 x+=_165.next(); 1266 1269 } 1267 1270 } … … 1272 1275 } 1273 1276 return x; 1274 },exhaust:function(_16 5){1277 },exhaust:function(_167){ 1275 1278 var self=MochiKit.Iter; 1276 _16 5=self.iter(_165);1279 _167=self.iter(_167); 1277 1280 try{ 1278 1281 while(true){ 1279 _16 5.next();1282 _167.next(); 1280 1283 } 1281 1284 } … … 1285 1288 } 1286 1289 } 1287 },forEach:function(_16 6,func,self){1290 },forEach:function(_168,func,self){ 1288 1291 var m=MochiKit.Base; 1289 1292 if(arguments.length>2){ 1290 1293 func=m.bind(func,self); 1291 1294 } 1292 if(m.isArrayLike(_16 6)){1293 try{ 1294 for(var i=0;i<_16 6.length;i++){1295 func(_16 6[i]);1295 if(m.isArrayLike(_168)){ 1296 try{ 1297 for(var i=0;i<_168.length;i++){ 1298 func(_168[i]); 1296 1299 } 1297 1300 } … … 1303 1306 }else{ 1304 1307 self=MochiKit.Iter; 1305 self.exhaust(self.imap(func,_16 6));1306 } 1307 },every:function(_1 68,func){1308 self.exhaust(self.imap(func,_168)); 1309 } 1310 },every:function(_170,func){ 1308 1311 var self=MochiKit.Iter; 1309 1312 try{ 1310 self.ifilterfalse(func,_1 68).next();1313 self.ifilterfalse(func,_170).next(); 1311 1314 return false; 1312 1315 } … … 1317 1320 return true; 1318 1321 } 1319 },sorted:function(_1 69,cmp){1320 var rval=MochiKit.Iter.list(_1 69);1322 },sorted:function(_171,cmp){ 1323 var rval=MochiKit.Iter.list(_171); 1321 1324 if(arguments.length==1){ 1322 1325 cmp=MochiKit.Base.compare; … … 1324 1327 rval.sort(cmp); 1325 1328 return rval; 1326 },reversed:function(_17 0){1327 var rval=MochiKit.Iter.list(_17 0);1329 },reversed:function(_172){ 1330 var rval=MochiKit.Iter.list(_172); 1328 1331 rval.reverse(); 1329 1332 return rval; 1330 },some:function(_17 1,func){1333 },some:function(_173,func){ 1331 1334 var self=MochiKit.Iter; 1332 1335 try{ 1333 self.ifilter(func,_17 1).next();1336 self.ifilter(func,_173).next(); 1334 1337 return true; 1335 1338 } … … 1340 1343 return false; 1341 1344 } 1342 },iextend:function(lst,_17 2){1343 if(MochiKit.Base.isArrayLike(_17 2)){1344 for(var i=0;i<_17 2.length;i++){1345 lst.push(_17 2[i]);1345 },iextend:function(lst,_174){ 1346 if(MochiKit.Base.isArrayLike(_174)){ 1347 for(var i=0;i<_174.length;i++){ 1348 lst.push(_174[i]); 1346 1349 } 1347 1350 }else{ 1348 1351 var self=MochiKit.Iter; 1349 _17 2=self.iter(_172);1352 _174=self.iter(_174); 1350 1353 try{ 1351 1354 while(true){ 1352 lst.push(_17 2.next());1355 lst.push(_174.next()); 1353 1356 } 1354 1357 } … … 1360 1363 } 1361 1364 return lst; 1362 },groupby:function(_17 3,_174){1365 },groupby:function(_175,_176){ 1363 1366 var m=MochiKit.Base; 1364 1367 var self=MochiKit.Iter; 1365 1368 if(arguments.length<2){ 1366 _17 4=m.operator.identity;1367 } 1368 _17 3=self.iter(_173);1369 _176=m.operator.identity; 1370 } 1371 _175=self.iter(_175); 1369 1372 var pk=undefined; 1370 1373 var k=undefined; 1371 1374 var v; 1372 1375 function fetch(){ 1373 v=_17 3.next();1374 k=_17 4(v);1376 v=_175.next(); 1377 k=_176(v); 1375 1378 } 1376 1379 function eat(){ … … 1379 1382 return ret; 1380 1383 } 1381 var _17 7=true;1384 var _179=true; 1382 1385 return {repr:function(){ 1383 1386 return "groupby(...)"; … … 1385 1388 while(k==pk){ 1386 1389 fetch(); 1387 if(_17 7){1388 _17 7=false;1390 if(_179){ 1391 _179=false; 1389 1392 break; 1390 1393 } … … 1401 1404 }}]; 1402 1405 }}; 1403 },groupby_as_array:function(_1 78,_179){1406 },groupby_as_array:function(_180,_181){ 1404 1407 var m=MochiKit.Base; 1405 1408 var self=MochiKit.Iter; 1406 1409 if(arguments.length<2){ 1407 _1 79=m.operator.identity;1408 } 1409 _1 78=self.iter(_178);1410 var _18 0=[];1411 var _18 1=true;1412 var _18 2;1410 _181=m.operator.identity; 1411 } 1412 _180=self.iter(_180); 1413 var _182=[]; 1414 var _183=true; 1415 var _184; 1413 1416 while(true){ 1414 1417 try{ 1415 var _18 3=_178.next();1416 var key=_1 79(_183);1418 var _185=_180.next(); 1419 var key=_181(_185); 1417 1420 } 1418 1421 catch(e){ … … 1422 1425 throw e; 1423 1426 } 1424 if(_18 1||key!=_182){1425 var _18 4=[];1426 _18 0.push([key,_184]);1427 } 1428 _18 4.push(_183);1429 _18 1=false;1430 _18 2=key;1431 } 1432 return _18 0;1433 },arrayLikeIter:function(_18 5){1427 if(_183||key!=_184){ 1428 var _186=[]; 1429 _182.push([key,_186]); 1430 } 1431 _186.push(_185); 1432 _183=false; 1433 _184=key; 1434 } 1435 return _182; 1436 },arrayLikeIter:function(_187){ 1434 1437 var i=0; 1435 1438 return {repr:function(){ 1436 1439 return "arrayLikeIter(...)"; 1437 1440 },toString:MochiKit.Base.forwardCall("repr"),next:function(){ 1438 if(i>=_18 5.length){1441 if(i>=_187.length){ 1439 1442 throw MochiKit.Iter.StopIteration; 1440 1443 } 1441 return _18 5[i++];1444 return _187[i++]; 1442 1445 }}; 1443 },hasIterateNext:function(_18 6){1444 return (_18 6&&typeof (_186.iterateNext)=="function");1445 },iterateNextIter:function(_18 7){1446 },hasIterateNext:function(_188){ 1447 return (_188&&typeof (_188.iterateNext)=="function"); 1448 },iterateNextIter:function(_189){ 1446 1449 return {repr:function(){ 1447 1450 return "iterateNextIter(...)"; 1448 1451 },toString:MochiKit.Base.forwardCall("repr"),next:function(){ 1449 var rval=_18 7.iterateNext();1452 var rval=_189.iterateNext(); 1450 1453 if(rval===null||rval===undefined){ 1451 1454 throw MochiKit.Iter.StopIteration; … … 1496 1499 MochiKit.Logging.EXPORT=["LogLevel","LogMessage","Logger","alertListener","logger","log","logError","logDebug","logFatal","logWarning"]; 1497 1500 MochiKit.Logging.EXPORT_OK=["logLevelAtLeast","isLogMessage","compareLogMessage"]; 1498 MochiKit.Logging.LogMessage=function(num,_1 89,info){1501 MochiKit.Logging.LogMessage=function(num,_191,info){ 1499 1502 this.num=num; 1500 this.level=_1 89;1503 this.level=_191; 1501 1504 this.info=info; 1502 1505 this.timestamp=new Date(); … … 1506 1509 return "LogMessage("+m.map(m.repr,[this.num,this.level,this.info]).join(", ")+")"; 1507 1510 },toString:MochiKit.Base.forwardCall("repr")}; 1508 MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_19 1){1511 MochiKit.Base.update(MochiKit.Logging,{logLevelAtLeast:function(_193){ 1509 1512 var self=MochiKit.Logging; 1510 if(typeof (_191)=="string"){1511 _191=self.LogLevel[_191];1512 }1513 return function(msg){1514 var _193=msg.level;1515 1513 if(typeof (_193)=="string"){ 1516 1514 _193=self.LogLevel[_193]; 1517 1515 } 1518 return _193>=_191; 1516 return function(msg){ 1517 var _195=msg.level; 1518 if(typeof (_195)=="string"){ 1519 _195=self.LogLevel[_195]; 1520 } 1521 return _195>=_193; 1519 1522 }; 1520 1523 },isLogMessage:function(){ 1521 var _19 4=MochiKit.Logging.LogMessage;1524 var _196=MochiKit.Logging.LogMessage; 1522 1525 for(var i=0;i<arguments.length;i++){ 1523 if(!(arguments[i] instanceof _19 4)){1526 if(!(arguments[i] instanceof _196)){ 1524 1527 return false; 1525 1528 } … … 1531 1534 alert("num: "+msg.num+"\nlevel: "+msg.level+"\ninfo: "+msg.info.join(" ")); 1532 1535 }}); 1533 MochiKit.Logging.Logger=function(_19 5){1536 MochiKit.Logging.Logger=function(_197){ 1534 1537 this.counter=0; 1535 if(typeof (_19 5)=="undefined"||_195==null){1536 _19 5=-1;1537 } 1538 this.maxSize=_19 5;1538 if(typeof (_197)=="undefined"||_197==null){ 1
