Take the 2008 Git User's Survey and help out! [ hide ]

public
Fork of sstephenson/prototype
Description: Prototype JavaScript framework
Homepage: http://prototypejs.org/
Clone URL: git://github.com/rmm5t/prototype.git
Search Repo:
Added optional context argument to Number#times
http://dev.rubyonrails.org/ticket/9252
rmm5t (author)
Thu Apr 03 13:20:26 -0700 2008
commit  59077cb00bb0bea8c88c629648c6a8256183f54c
tree    d624da7d7cf30a516f588cb038806a0795d3e6cd
parent  1c00700894a23599c3d0c7be97951f2649acae2d
...
7
8
9
10
11
 
 
12
13
14
...
24
25
26
27
28
 
...
7
8
9
 
 
10
11
12
13
14
...
24
25
26
 
27
28
0
@@ -7,8 +7,8 @@ Object.extend(Number.prototype, {
0
     return this + 1;
0
   },
0
   
0
- times: function(iterator) {
0
- $R(0, this, true).each(iterator);
0
+ times: function(iterator, context) {
0
+ $R(0, this, true).each(iterator, context);
0
     return this;
0
   },
0
   
0
@@ -24,4 +24,4 @@ Object.extend(Number.prototype, {
0
 
0
 $w('abs round ceil floor').each(function(method){
0
   Number.prototype[method] = Math[method].methodize();
0
-});
0
\ No newline at end of file
0
+});
...
53
54
55
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
58
59
...
53
54
55
 
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
0
@@ -53,7 +53,21 @@
0
       this.assertEqual('null', Number.NaN.toJSON());
0
       this.assertEqual('0', (0).toJSON());
0
       this.assertEqual('-293', (-293).toJSON());
0
- }
0
+ },
0
+
0
+ testTimes: function() {
0
+ var counter = 0;
0
+ (3).times(function() { counter++; });
0
+ this.assertEqual(3, counter);
0
+
0
+ var last = 0;
0
+ (3).times(function(n) { last = n; });
0
+ this.assertEqual(2, last);
0
+
0
+ var result = 0;
0
+ (3).times(function() { result += this.n; }, { n: 2 });
0
+ this.assertEqual(6, result);
0
+ }
0
 
0
   });
0
 

Comments

    No one has commented yet.