public
Description: Prototype JavaScript framework
Homepage: http://prototypejs.org/
Clone URL: git://github.com/sstephenson/prototype.git
Add context argument to Number#times
samleb (author)
Mon May 05 06:17:08 -0700 2008
madrobby (committer)
Tue May 06 02:11:22 -0700 2008
commit  451ce6aad3d218b270a7660bf523ffaec80f445f
tree    26631cd03174e7e9a21297c3b243e3a6bb0feeea
parent  396c0a5afd324876a199720b710529146aa9a529
...
7
8
9
10
11
 
 
12
13
14
...
7
8
9
 
 
10
11
12
13
14
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
   
...
30
31
32
 
 
 
 
 
 
 
 
 
 
33
34
35
...
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
0
@@ -30,5 +30,15 @@ new Test.Unit.Runner({
0
     this.assertEqual('null', Number.NaN.toJSON());
0
     this.assertEqual('0', (0).toJSON());
0
     this.assertEqual('-293', (-293).toJSON());
0
+ },
0
+
0
+ testNumberTimes: function() {
0
+ var results = [];
0
+ (5).times(function(i) { results.push(i) });
0
+ this.assertEnumEqual($R(0, 4), results);
0
+
0
+ results = [];
0
+ (5).times(function(i) { results.push(i * this.i) }, { i: 2 });
0
+ this.assertEnumEqual([0, 2, 4, 6, 8], results);
0
   }
0
 });
0
\ No newline at end of file

Comments

    No one has commented yet.