when passing an array to Ox.values, return a clone, not the original array

This commit is contained in:
rolux 2012-05-27 22:08:08 +02:00
parent 9cc9a167f8
commit 30e59f5538

View file

@ -313,8 +313,8 @@ Ox.map <f> Transforms the values of an array, object or string
objects and strings.
> Ox.map([2, 1, 0], function(v, i) { return v == i; })
[false, true, false]
> Ox.map({a: 'a', b: 'a', c: 'a'}, function(v, k) { return v == k; })
{a: true, b: false, c: false}
> Ox.map({a: 'b', b: 'b', c: 'b'}, function(v, k) { return v == k; })
{a: false, b: true, c: false}
> Ox.map('foo', function(v) { return v.toUpperCase(); })
'FOO'
> Ox.map([,], function(v, i) { return i; })
@ -537,7 +537,7 @@ Ox.values <f> Returns the values of a collection
Ox.values = function(collection) {
var ret, type = Ox.typeOf(collection);
if (type == 'array') {
ret = collection;
ret = Ox.clone(collection);
} else if (type == 'object') {
ret = [];
Ox.forEach(collection, function(value) {