* Add @fileoverview JSDoc comment
* Move static methods down to the bottom of the file to circumvent a strange bug that prevents documentation from being generated.
This commit is contained in:
parent
da7bdcfba0
commit
486e9a5836
4 changed files with 130 additions and 119 deletions
|
@ -9,29 +9,14 @@
|
|||
* Copyright 1998-2006 Helma Software. All Rights Reserved.
|
||||
*
|
||||
* $RCSfile: Number.js,v $
|
||||
* $Author: tobi $
|
||||
* $Revision: 1.3 $
|
||||
* $Date: 2006/07/18 08:24:59 $
|
||||
* $Author: robert $
|
||||
* $Revision: 1.4 $
|
||||
* $Date: 2006/12/14 17:28:43 $
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* factory to create functions for sorting objects in an array
|
||||
* @param String name of the field each object is compared with
|
||||
* @param Number order (ascending or descending)
|
||||
* @return Function ready for use in Array.prototype.sort
|
||||
* @fileoverview Adds useful methods to the JavaScript Number type.
|
||||
*/
|
||||
Number.Sorter = function(field, order) {
|
||||
if (!order)
|
||||
order = 1;
|
||||
return function(a, b) {
|
||||
return (a[field] - b[field]) * order;
|
||||
};
|
||||
};
|
||||
|
||||
Number.Sorter.ASC = 1;
|
||||
Number.Sorter.DESC = -1;
|
||||
|
||||
|
||||
/**
|
||||
* format a Number to a String
|
||||
|
@ -67,6 +52,24 @@ Number.prototype.toPercent = function(total, fmt, locale) {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* factory to create functions for sorting objects in an array
|
||||
* @param String name of the field each object is compared with
|
||||
* @param Number order (ascending or descending)
|
||||
* @return Function ready for use in Array.prototype.sort
|
||||
*/
|
||||
Number.Sorter = function(field, order) {
|
||||
if (!order)
|
||||
order = 1;
|
||||
return function(a, b) {
|
||||
return (a[field] - b[field]) * order;
|
||||
};
|
||||
};
|
||||
|
||||
Number.Sorter.ASC = 1;
|
||||
Number.Sorter.DESC = -1;
|
||||
|
||||
|
||||
// prevent any newly added properties from being enumerated
|
||||
for (var i in Number)
|
||||
Number.dontEnum(i);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue