Pastebin
Paste #2001: 25-type-str.js
< previous paste - next paste>
Pasted by chrivers
var str = __inherit(object);
str.__name__ = 'str';
str.prototype.__class__ = str;
str.prototype.MARK = "str";
str.prototype.__init__ = function(s) {
if (!defined(s)) {
this._obj = '';
} else {
if (typeof(s) === "string") {
this._obj = s;
} else if (defined(s.toString)) {
this._obj = s.toString();
} else if (defined(s.__str__)) {
this._obj = js(s.__str__());
} else
this._obj = js(s);
}
};
str.prototype.__str__ = function () {
return this;
};
str.prototype.__eq__ = function (other) {
if (other.__class__ == this.__class__) {
if (len(this) != len(other))
return false;
for (var i = 0; i < len(this); i++) {
if (this._obj[i] != other._obj[i])
return false;
}
return true;
} else
return false;
};
str.prototype.toString = function () {
return js(this.__str__());
};
New Paste
Go to most recent paste.