* Fork - LGPL
* <script type="text/javascript">
*/
+
// usage:
// Seed.include('String.js');
-XObject = imports.XObject.XObject;
+
+const XObject = imports.XObject.XObject;
-XObject.extend(String,
+XObject.extend(String,
{
-
+
/** @scope String */
-
+
/**
* Escapes the passed string for ' and \
* @param {String} string The string to escape
}
return result;
},
- /**
+
+ /**
* Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
* token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
* <pre><code>
return args[i];
});
},
-
/**
* Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
return this.htmlEncode(args[i]);
});
},
-
+
/**
* Convert certain characters (&, <, >, and ') to their HTML character equivalents for literal display in web pages.
* @param {String} value The string to encode
String(value).replace(/&/g, "&"
).replace(/>/g, ">").replace(/</g, "<").replace(/"/g, """);
}
-
-
}
);
* @param {String} other The new value to use if the string already equals the first value passed in
* @return {String} The new value
*/
-
+
XObject.extend(String.prototype, {
-
+
toggle : function(value, other){
return this == value ? other : value;
},
-
+
trim : function (toTrim) {
var out = this.ltrim(toTrim);
out = out.rtrim(toTrim);
return out;
},
-
+
ltrim : function (toTrim) {
if (this.substr(0, toTrim.length) == toTrim) {
return this.slice(toTrim.length);
}
-
+
return this;
},
-
+
rtrim : function (toTrim) {
if (this.substr(this.length - toTrim.length) == toTrim) {
return this.slice(0, this.length - toTrim.length);
}
-
+
return this;
}
-
-
-
-});
\ No newline at end of file
+});