Comparing version
24
index.js
if (!Array.prototype.swap) { | ||
module.exports = Array.prototype.swap = function(x, y) { | ||
var swap = function(x, y) { | ||
this[x] = this.splice(y, 1, this[x])[0]; | ||
return this; | ||
}(Array.prototype.swap); | ||
} | ||
return this; | ||
}; | ||
if (Object.defineProperty) { | ||
try { | ||
Object.defineProperty(Array.prototype, 'swap', { | ||
value: swap, | ||
configurable: true, | ||
enumerable: false, | ||
writable: true | ||
}); | ||
} catch(e) {} | ||
} | ||
Array.prototype.swap = swap; | ||
module.exports = swap; | ||
} |
{ | ||
"name": "array-swap", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Swapping two items in a javascript array - Array.prototype.swap", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
981
26.91%17
240%0
-100%