add alternative signature to Ox.extend

This commit is contained in:
rolux 2012-05-31 12:35:09 +02:00
parent 8c347d9009
commit f8ab51fa40

View file

@ -4,9 +4,15 @@
Ox.extend <function> Extends an object with one or more other objects
> Ox.extend({a: 1, b: 1, c: 1}, {b: 2, c: 2}, {c: 3})
{a: 1, b: 2, c: 3}
> Ox.extend({a: 1}, 'b', 2)
{a: 1, b: 2}
@*/
Ox.extend = function(object) {
Ox.forEach(Ox.slice(arguments, 1), function(argument, i) {
var args = Ox.slice(arguments, 1);
if (args.length == 2 && !Ox.isObject(args[0])) {
args = [Ox.makeObject(args)];
}
Ox.forEach(args, function(argument, i) {
Ox.forEach(argument, function(value, key) {
object[key] = value;
});