Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "protos.js", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "String and Array prototypes for a more easy life", | ||
@@ -5,0 +5,0 @@ "main": "protos.js", |
@@ -44,2 +44,6 @@ /* | ||
Array.prototype.choice = function() { | ||
return this[Math.floor(Math.random()*this.length)]; | ||
} | ||
Array.prototype.hasSimilar = function(str, min_ratio) { | ||
@@ -55,2 +59,8 @@ var hash = str.hash(); | ||
Array.prototype.unique = function() { | ||
return this.filter(function(item, pos, self) { | ||
return self.indexOf(item) == pos; | ||
}); | ||
} | ||
Array.prototype.load = function(filename) { | ||
@@ -68,2 +78,21 @@ var arr = this; | ||
Array.prototype.clear = function() { | ||
this = []; | ||
} | ||
Array.prototype.sched = function(millis, cb) { | ||
if (this.length == 0) | ||
return; | ||
if (!this.last) | ||
this.last = 0; | ||
cb(this[this.last]); | ||
this.last++; | ||
if (this.last==this.length) | ||
this.last = 0; | ||
setTimeout(this.sched.bind(this, millis, cb), millis); | ||
} | ||
String.prototype.load = function(filename, cb) { | ||
@@ -70,0 +99,0 @@ if (cb) { |
Sorry, the diff of this file is not supported yet
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
5080
122
75