[Jspro-cvs] jsPro array.js,1.22,1.23
Brought to you by:
wigleys
|
From: <wi...@us...> - 2003-09-12 14:22:11
|
Update of /cvsroot/jspro/jsPro
In directory sc8-pr-cvs1:/tmp/cvs-serv27295
Modified Files:
array.js
Log Message:
- new keyChangeCase method
- addition of @summary comments
Index: array.js
===================================================================
RCS file: /cvsroot/jspro/jsPro/array.js,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** array.js 12 Aug 2003 13:05:54 -0000 1.22
--- array.js 12 Sep 2003 14:22:08 -0000 1.23
***************
*** 27,33 ****
--- 27,89 ----
/**
+ * Changes the case of array keys to upper or lowercase
+ *
+ * @summary change key case
+ * @author Stuart Wigley
+ * @version 1.0, 09/12/03
+ * @interface <code>Array.changeKeyCase(iCase)</code>
+ * @param iCase an integer representing the case (lowercase: 0;
+ * uppercase: 1;)
+ * @return an array with keys changed to upper or lowercase
+ * @return <code>null</code> if an exception is encountered
+ * @throws IllegalArgumentException
+ * @throws TypeMismatchException
+ */
+ Array.prototype.changeKeyCase = function(iCase) {
+
+ try {
+
+ var vError = null;
+ var iArrayLength = this.length;
+ var iNumArguments = arguments.length;
+
+ if (iNumArguments != 1) {
+ throw vError = new IllegalArgumentException('Array.changeKeyCase', 1, iNumArguments);
+ }
+
+ if ((typeof iCase != 'number') || (parseInt(iCase.toString()) != iCase)) {
+ throw vError = new TypeMismatchException('Array.changeKeyCase', 'number', typeof iCase);
+ }
+
+ for (var sKey in this) {
+ if (this.hasOwnProperty(sKey)) {
+
+ var sKeyCase = (iCase == 1) ? sKey.toUpperCase() : sKey.toLowerCase();
+ if (sKeyCase != sKey) {
+
+ this[sKeyCase] = this[sKey];
+ delete this[sKey];
+ }
+ }
+ }
+ }
+ catch (vError) {
+
+ if (vError instanceof Error) {
+ vError.handleError();
+ }
+ }
+ finally {
+
+ return vError ? null : this;
+ }
+ }
+
+
+ /**
* Returns an array of 'chunks' where each 'chunk' is an array of
* <code>iChunkSize</code> formed from this array.
*
+ * @summary split into chunks
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 90,93 ****
--- 146,150 ----
* of occurrences of that member's key in this array.
*
+ * @summary count occurrence of values
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 135,138 ****
--- 192,196 ----
* specified).
*
+ * @summary coefficient of variation
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 233,236 ****
--- 291,295 ----
* length arguments are specified) with a value of any data type.
*
+ * @summary fill
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 313,316 ****
--- 372,376 ----
* of array members (if the optional start and length arguments are specified).
*
+ * @summary maximum value
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 397,400 ****
--- 457,461 ----
* members (if the optional start and length arguments are specified).
*
+ * @summary mean
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 485,488 ****
--- 546,550 ----
* array members (if the optional start and length arguments are specified).
*
+ * @summary median
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 585,588 ****
--- 647,651 ----
* of array members (if the optional start and length arguments are specified).
*
+ * @summary minimum value
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 669,672 ****
--- 732,736 ----
* array members (if the optional start and length arguments are specified).
*
+ * @summary product
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 757,760 ****
--- 821,825 ----
* array members (if the optional start and length arguments are specified).
*
+ * @summary range
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 856,859 ****
--- 921,925 ----
* specified).
*
+ * @summary standard deviation
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 947,950 ****
--- 1013,1017 ----
* members (if the optional start and length arguments are specified).
*
+ * @summary sum
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 1034,1037 ****
--- 1101,1105 ----
* Swaps the values of two array members at the specified indices.
*
+ * @summary swap two members
* @author Stuart Wigley
* @author Randolph Fielding
***************
*** 1096,1099 ****
--- 1164,1168 ----
* specified).
*
+ * @summary unbiased variance
* @author Stuart Wigley
* @author Randolph Fielding
|