String.js
authorAlan Knowles <alan@roojs.com>
Wed, 23 Nov 2011 03:01:07 +0000 (11:01 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 23 Nov 2011 03:01:07 +0000 (11:01 +0800)
String.js

index ddf883d..9a221bb 100644 (file)
--- a/String.js
+++ b/String.js
@@ -109,35 +109,45 @@ String = XObject.extend(String,
     }
 );
 
-    /**
-     * Utility function that allows you to easily switch a string between two alternating values.  The passed value
-     * is compared to the current string, and if they are equal, the other value that was passed in is returned.  If
-     * they are already different, the first value passed in is returned.  Note that this method returns the new value
-     * but does not change the current string.
-     * <pre><code>
-    // alternate sort directions
-    sort = sort.toggle('ASC', 'DESC');
-
-    // instead of conditional logic:
-    sort = (sort == 'ASC' ? 'DESC' : 'ASC');
-    </code></pre>
-     * @param {String} value The value to compare to the current string
-     * @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,  {
-        
+       
+        /**
+         * Utility function that allows you to easily switch a string between two alternating values.  The passed value
+         * is compared to the current string, and if they are equal, the other value that was passed in is returned.  If
+         * they are already different, the first value passed in is returned.  Note that this method returns the new value
+         * but does not change the current string.
+         * <pre><code>
+        // alternate sort directions
+        sort = sort.toggle('ASC', 'DESC');
+    
+        // instead of conditional logic:
+        sort = (sort == 'ASC' ? 'DESC' : 'ASC');
+        </code></pre>
+         * @param {String} value The value to compare to the current string
+         * @param {String} other The new value to use if the string already equals the first value passed in
+         * @return {String} The new value
+         */
+         
         toggle : function(value, other){
             return this == value ? other : value;
         },
-        
+        /**
+         * trim a string from the beginning and end
+         * This is NOT whitespace strip, it is prefix/suffix stripping
+         * 
+         * @param {String} string to strip.
+         */
         trim : function (toTrim) {
             var out = this.ltrim(toTrim);
             out = out.rtrim(toTrim);
             return out;
         },
-        
+        /**
+         * trim a string from the beginning
+         * This is NOT whitespace strip, it is prefix stripping
+         * 
+         * @param {String} string to remove if it exists.
+         */
         ltrim : function (toTrim) {
             if (this.substr(0, toTrim.length) == toTrim) {
                 return this.slice(toTrim.length);
@@ -145,7 +155,12 @@ XObject.extend(String.prototype,  {
             
             return this;
         },
-        
+        /**
+         * trim a string from the end
+         * This is NOT whitespace strip, it is suffix stripping
+         * 
+         * @param {String} string to remove if it exists.
+         */
         rtrim : function (toTrim) {
             if (this.substr(this.length - toTrim.length) == toTrim) {
                 return this.slice(0, this.length - toTrim.length);