From 25c25c76c735ec1838364bab724b2137658e827e Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Fri, 30 Mar 2012 14:11:29 +0000 Subject: [PATCH] minor changes, mostly documentation --- source/Ox/js/Collection.js | 4 ++-- source/Ox/js/Format.js | 7 +++++-- source/Ox/js/Math.js | 6 +++--- source/Ox/js/Object.js | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/source/Ox/js/Collection.js b/source/Ox/js/Collection.js index 2354f97b..9dde230a 100644 --- a/source/Ox/js/Collection.js +++ b/source/Ox/js/Collection.js @@ -648,9 +648,9 @@ Ox.sum = function(col) { /*@ Ox.toArray 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) { diff --git a/source/Ox/js/Format.js b/source/Ox/js/Format.js index 8c970026..a08cd9df 100644 --- a/source/Ox/js/Format.js +++ b/source/Ox/js/Format.js @@ -483,8 +483,9 @@ Ox.formatOrdinal 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 Basic string formatting 'foobar' @*/ +// fixme: Ox.formatRoman() ? + Ox.formatString = function (str, obj) { return str.replace(/\{([^}]+)\}/g, function(str, match) { return obj[match]; diff --git a/source/Ox/js/Math.js b/source/Ox/js/Math.js index 6c8b7c17..b69236fa 100644 --- a/source/Ox/js/Math.js +++ b/source/Ox/js/Math.js @@ -103,9 +103,9 @@ Ox.rad = function(deg) { /*@ Ox.random 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) + () -> 0 or 1 + (max) -> Integer between 0 (inclusive) and max (exclusive) + (min, max) -> Integer between min (inclusive) and max (exclusive) > [0, 1].indexOf(Ox.random()) > -1 true > [0, 1, 2].indexOf(Ox.random(3)) > -1 diff --git a/source/Ox/js/Object.js b/source/Ox/js/Object.js index 3a021489..c3072b0f 100644 --- a/source/Ox/js/Object.js +++ b/source/Ox/js/Object.js @@ -23,7 +23,7 @@ Ox.keyOf 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; }