mirror of
https://github.com/reality/dbot.git
synced 2024-12-24 03:33:07 +01:00
added more to snippets
This commit is contained in:
parent
3d843f6c96
commit
e31cb1beb7
22
snippets.js
22
snippets.js
@ -15,6 +15,18 @@ Array.prototype.collect = function(fun) {
|
||||
}
|
||||
};
|
||||
|
||||
Array.prototype.include = function(value) {
|
||||
var includes = false;
|
||||
for(var i=0;i<this.length;i++) {
|
||||
if(this[i] == value) {
|
||||
includes = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return includes;
|
||||
};
|
||||
|
||||
/*** String ***/
|
||||
|
||||
String.prototype.endsWith = function(needle) {
|
||||
@ -27,7 +39,7 @@ String.prototype.endsWith = function(needle) {
|
||||
};
|
||||
|
||||
String.prototype.startsWith = function(needle) {
|
||||
var start = this.slice(0, this.length - needle.length);
|
||||
var start = this.slice(0, needle.length);
|
||||
if(needle === start) {
|
||||
return true;
|
||||
} else {
|
||||
@ -44,3 +56,11 @@ Object.prototype.isFunction = function(obj) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Object.prototype.isArray = function(obj) {
|
||||
if(Object.prototype.toString.call(obj) === '[object Array]') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user