make Ox.reverse() work for arrays
This commit is contained in:
parent
1576ba4c48
commit
1f7796b0f8
4 changed files with 18 additions and 12 deletions
|
@ -516,6 +516,19 @@ Ox.min = function(col) {
|
||||||
return Math.min.apply(Math, Ox.values(col));
|
return Math.min.apply(Math, Ox.values(col));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*@
|
||||||
|
Ox.reverse <f> Reverses an array or string
|
||||||
|
> Ox.reverse([1, 2, 3])
|
||||||
|
[3, 2, 1]
|
||||||
|
> Ox.reverse('foobar')
|
||||||
|
'raboof'
|
||||||
|
@*/
|
||||||
|
Ox.reverse = function(col) {
|
||||||
|
return Ox.isArray(col)
|
||||||
|
? Ox.clone(col).reverse()
|
||||||
|
: col.toString().split('').reverse().join('');
|
||||||
|
};
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
Ox.setPropertyOnce <f> Sets a property once
|
Ox.setPropertyOnce <f> Sets a property once
|
||||||
Given a array of objects, each of which has a property with a boolean
|
Given a array of objects, each of which has a property with a boolean
|
||||||
|
|
|
@ -506,7 +506,7 @@ Ox.formatOrdinal <f> Formats a number as an ordinal
|
||||||
@*/
|
@*/
|
||||||
Ox.formatOrdinal = function(num) {
|
Ox.formatOrdinal = function(num) {
|
||||||
var str = num.toString(),
|
var str = num.toString(),
|
||||||
len = str.length
|
len = str.length,
|
||||||
end = str[len - 1],
|
end = str[len - 1],
|
||||||
ten = len > 1 && str[len - 2] == '1';
|
ten = len > 1 && str[len - 2] == '1';
|
||||||
if (end == '1' && !ten) {
|
if (end == '1' && !ten) {
|
||||||
|
|
|
@ -246,6 +246,8 @@
|
||||||
> Ox.containsArea(Ox.test.areas[2], Ox.test.areas[3])
|
> Ox.containsArea(Ox.test.areas[2], Ox.test.areas[3])
|
||||||
true
|
true
|
||||||
@*/
|
@*/
|
||||||
|
// FIXME: Shouldn't this be rewritten as a test
|
||||||
|
// if the intersection is equal to the inner area?
|
||||||
Ox.containsArea = function(areaA, areaB) {
|
Ox.containsArea = function(areaA, areaB) {
|
||||||
// If an area crosses the dateline,
|
// If an area crosses the dateline,
|
||||||
// we split it into two parts,
|
// we split it into two parts,
|
||||||
|
@ -287,9 +289,9 @@
|
||||||
> Ox.intersectAreas([Ox.test.areas[2], Ox.test.areas[3]])
|
> Ox.intersectAreas([Ox.test.areas[2], Ox.test.areas[3]])
|
||||||
{sw: {lat: 25, lng: -155}, ne: {lat: 30, lng: -150}}
|
{sw: {lat: 25, lng: -155}, ne: {lat: 30, lng: -150}}
|
||||||
@*/
|
@*/
|
||||||
|
// FIXME: handle the a corner case where
|
||||||
|
// two areas have two intersections
|
||||||
Ox.intersectAreas = function(areas) {
|
Ox.intersectAreas = function(areas) {
|
||||||
// FIXME: handle the a corner case where
|
|
||||||
// two areas have two intersections
|
|
||||||
var intersections, ret;
|
var intersections, ret;
|
||||||
// If an area crosses the dateline,
|
// If an area crosses the dateline,
|
||||||
// we split it into two parts,
|
// we split it into two parts,
|
||||||
|
|
|
@ -410,15 +410,6 @@ Ox.repeat = function(val, num) {
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*@
|
|
||||||
Ox.reverse <f> Reverses a string
|
|
||||||
> Ox.reverse('foobar')
|
|
||||||
'raboof'
|
|
||||||
@*/
|
|
||||||
Ox.reverse = function(str) {
|
|
||||||
return str.toString().split('').reverse().join('');
|
|
||||||
};
|
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
Ox.startsWith <f> Checks if a string starts with a given substring
|
Ox.startsWith <f> Checks if a string starts with a given substring
|
||||||
If the substring is a string literal (and not a variable),
|
If the substring is a string literal (and not a variable),
|
||||||
|
|
Loading…
Reference in a new issue