Comparing version 0.0.3 to 0.0.4
39
index.js
@@ -14,41 +14,2 @@ 'use strict'; | ||
Array.prototype.move = function(old_index, new_index) { | ||
if (new_index >= this.length) { | ||
var k = new_index - this.length; | ||
while ((k--) + 1) { | ||
this.push(undefined); | ||
} | ||
} | ||
this.splice(new_index, 0, this.splice(old_index, 1)[0]); | ||
// return this; // for testing purposes | ||
}; | ||
Array.prototype.moveUp = function(value, by) { | ||
var index = this.indexOf(value), | ||
newPos = index - (by || 1); | ||
if(index === -1) | ||
throw new Error("Element not found in array"); | ||
if(newPos < 0) | ||
newPos = 0; | ||
this.splice(index,1); | ||
this.splice(newPos,0,value); | ||
}; | ||
Array.prototype.moveDown = function(value, by) { | ||
var index = this.indexOf(value), | ||
newPos = index + (by || 1); | ||
if(index === -1) | ||
throw new Error("Element not found in array"); | ||
if(newPos >= this.length) | ||
newPos = this.length; | ||
this.splice(index, 1); | ||
this.splice(newPos,0,value); | ||
}; | ||
if(!Array.prototype.indexOf) { | ||
@@ -55,0 +16,0 @@ Array.prototype.indexOf = function(what, i) { |
{ | ||
"name": "ab-array", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Array prototype addons", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3137
32