Permalink
Browse files

Removed global variables.

  • Loading branch information...
1 parent 33f65df commit 1752478722d8809b4559ea8bb169a1956cdaf11c Oliver Morgan committed Oct 14, 2011
Showing with 14 additions and 16 deletions.
  1. +4 −6 lib/array.js
  2. +3 −3 lib/string.js
  3. +6 −6 test/array.js
  4. +1 −1 test/object.js
View
@@ -128,10 +128,8 @@ extend(Array.prototype, {
*
* @returns bool
*/
- if (arguments.length === 0)
- return false;
- else if (arguments.length === 1)
- return !! ~ this.indexOf(arguments[0]);
+ if (arguments.length === 0) return false;
+ else if (arguments.length === 1) return !! ~ this.indexOf(arguments[0]);
else {
return Array.prototype.slice.call(arguments).every(function(arr) {
return !! ~ this.indexOf(arr);
@@ -154,7 +152,7 @@ extend(Array.prototype, {
* @returns self
*/
if (arguments.length === 0) return this;
- exclude = Array.prototype.slice.call(arguments);
+ var exclude = Array.prototype.slice.call(arguments);
return this.filter$(function (val) {
return ! exclude.contains(val);
@@ -174,7 +172,7 @@ extend(Array.prototype, {
* @returns array
*/
if (arguments.length === 0) return this.clone();
- exclude = Array.prototype.slice.call(arguments);
+ var exclude = Array.prototype.slice.call(arguments);
return this.filter(function (val) {
return ! exclude.contains(val);
View
@@ -372,7 +372,7 @@ extend(String.prototype, {
* // returns 'SGVsbG8gV29ybGQ='
*/
var key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', output = '', input = this.valueOf();
- for (i = 0; i < input.length; i += 3) {
+ for (var i = 0; i < input.length; i += 3) {
var c1 = input.charCodeAt(i), c2 = input.charCodeAt(i + 1), c3 = input.charCodeAt(i + 2);
var e1 = c1 >> 2,
e2 = ((c1 & 3) << 4) | (c2 >> 4),
@@ -402,7 +402,7 @@ extend(String.prototype, {
var key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', output = '', input = this;
return input.split("\n").map(function (line) {
var output = '';
- for (i = 0; i < line.length; i += 4) {
+ for (var i = 0; i < line.length; i += 4) {
var e1 = key.indexOf(line.charAt(i)),
e2 = key.indexOf(line.charAt(i + 1)),
e3 = key.indexOf(line.charAt(i + 2)),
@@ -449,7 +449,7 @@ extend(String.prototype, {
width = width || '',
precision = precision || '';
- val = vals[+flags ? flags - 1 : index]; index++;
+ var val = vals[+flags ? flags - 1 : index]; index++;
if (type.match(/[duobxXf]{1}/)) val = Number(val);
else val = String(val);
View
@@ -48,20 +48,20 @@ test('Array#swap$', function () {
});
test('Array#contains', function () {
- ok([1,2,3].contains(1,2)); // 2
- strictEqual([1,2,3].contains(4), false); // 3
- strictEqual([1,2,3].contains(), false); // 4
- strictEqual([].contains(2), false); // 5
+ ok([1,2,3].contains(1,2)); // 1
+ strictEqual([1,2,3].contains(4), false); // 2
+ strictEqual([1,2,3].contains(), false); // 3
+ strictEqual([].contains(2), false); // 4
});
-test('Array#remove', function () {
+test('Array#remove$', function () {
var a = [1,2,3];
ok(a.remove(2,3) !== a);
deepEqual(a.remove(2,3), [1,2,3].remove$(2,3));
// Further testing is done in #remove$
});
-test('Array#remove$', function () {
+test('Array#remove', function () {
var arr = [1,2,3];
arr.foo = 'bar';
View
@@ -90,7 +90,7 @@ test('Object.map$', function () {
test('Object.getOwnPropertyDescriptors', function () {
- desc = {
+ var desc = {
bar:
{ value: function () { },
writable: false,

0 comments on commit 1752478

Please sign in to comment.