JSFiddle - React, Tailwind, and code Playground
by a_robson
HTML
<div id="sandwiches" />
<br/>
<div id="proxy" />
JavaScript
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
};
String.prototype.ltrim = function() {
return this.replace(/^\s+/,"");
};
String.prototype.rtrim = function() {
return this.replace(/\s+$/,"");
};
Array.prototype.map = function(closure) {
var result, index, length;
index = 0;
length = this.length;
result = [];
for(; index < length; index ++ ) {
try {
result.push( closure( this[index] ) );
}
catch( ex ) { }
}
return result;
};
Array.prototype.foreach = function(closure) {
var index, length;
index = 0;
length = this.length;
for(; index < length; index ++ ) {
try {
closure( this[index] );
}
catch( ex ) { document.write( "error in foreach: " + ex + "<br/>"); }
}
};
Array.prototype.reduce = function(predicate) {
var index, length;
index = 0;
length = this.length;
var result;
result = [];
var element;
for(; index < length; index++) {
try {
if( predicate( this[element] ) ) {
result.push( this[element] );
}
}
catch( ex ) { }
}
return result;
};
Array.prototype.first = function(predicate) {
var index, length;
index = 0;
length = this.length;
for(; index < length; index++ ) {
try {
if( predicate( this[index] ) ) {
return this[index];
}
}
catch( ex ) { }
}
return undefined;
};
var CallbackList = function(name) {
this.name = name;
this.callbacks = [];
this.enlist = function( callback ) {
this.callbacks.push( callback );
};
this.matches = function( topic ) {
return ( this.name == "*" ||
topic === "" ||
topic === undefined ||
( topic.substring(0, this.name.length ) == this.name &&
name !== "" ) );
};
...