42 lines
No EOL
920 B
JavaScript
42 lines
No EOL
920 B
JavaScript
define(function(e, d) {
|
|
d.stringReverse = function(a) {
|
|
return a.split("").reverse().join("")
|
|
};
|
|
d.stringRepeat = function(a, b) {
|
|
return(new Array(b + 1)).join(a)
|
|
};
|
|
d.copyObject = function(a) {
|
|
var b = {};
|
|
for(var c in a) {
|
|
b[c] = a[c]
|
|
}return b
|
|
};
|
|
d.arrayToMap = function(a) {
|
|
for(var b = {}, c = 0;c < a.length;c++) {
|
|
b[a[c]] = 1
|
|
}return b
|
|
};
|
|
d.arrayRemove = function(a, b) {
|
|
for(var c = 0;c <= a.length;c++) {
|
|
b === a[c] && a.splice(c, 1)
|
|
}
|
|
};
|
|
d.escapeRegExp = function(a) {
|
|
return a.replace(/([.*+?^${}()|[\]\/\\])/g, "\\$1")
|
|
};
|
|
d.deferredCall = function(a) {
|
|
var b = null, c = function() {
|
|
b = null;
|
|
a()
|
|
};
|
|
return{schedule:function() {
|
|
b || (b = setTimeout(c, 0))
|
|
}, call:function() {
|
|
this.cancel();
|
|
a()
|
|
}, cancel:function() {
|
|
clearTimeout(b);
|
|
b = null
|
|
}}
|
|
}
|
|
}); |