minor changes, mostly documentation

This commit is contained in:
rlx 2012-03-30 14:11:29 +00:00
parent 9032821f14
commit 25c25c76c7
4 changed files with 11 additions and 8 deletions

View file

@ -648,9 +648,9 @@ Ox.sum = function(col) {
/*@
Ox.toArray <f> Wraps any non-array in an array.
>>> Ox.toArray('foo')
> Ox.toArray('foo')
['foo']
>>> Ox.toArray(['foo'])
> Ox.toArray(['foo'])
['foo']
@*/
Ox.toArray = function(obj) {

View file

@ -483,8 +483,9 @@ Ox.formatOrdinal <f> Formats a number as an ordinal
@*/
Ox.formatOrdinal = function(num) {
var str = num.toString(),
end = str[str.length - 1],
ten = str.length > 1 && str[str.length - 2] == '1';
len = str.length
end = str[len - 1],
ten = len > 1 && str[len - 2] == '1';
if (end == '1' && !ten) {
str += 'st';
} else if (end == '2' && !ten) {
@ -524,6 +525,8 @@ Ox.formatString <f> Basic string formatting
'foobar'
@*/
// fixme: Ox.formatRoman() ?
Ox.formatString = function (str, obj) {
return str.replace(/\{([^}]+)\}/g, function(str, match) {
return obj[match];

View file

@ -103,9 +103,9 @@ Ox.rad = function(deg) {
/*@
Ox.random <f> Returns a random integer within a given range
() -> 0 or 1
(max) -> Integer between 0 (inclusive) and max (exclusive)
(min, max) -> Integer between min (inclusive) and max (exclusive)
() -> <n> 0 or 1
(max) -> <n> Integer between 0 (inclusive) and max (exclusive)
(min, max) -> <n> Integer between min (inclusive) and max (exclusive)
> [0, 1].indexOf(Ox.random()) > -1
true
> [0, 1, 2].indexOf(Ox.random(3)) > -1

View file

@ -23,7 +23,7 @@ Ox.keyOf <f> Equivalent of [].indexOf for objects
Ox.keyOf = function(obj, val) {
var key;
Ox.forEach(obj, function(v, k) {
if (v == val) {
if (v === val) {
key = k;
return false;
}