forked from as3/as3-utils
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmerge.as
More file actions
32 lines (31 loc) · 730 Bytes
/
merge.as
File metadata and controls
32 lines (31 loc) · 730 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package utils.object
{
/**
* Merge enumerable fields from a source Object to a target Object.
*
* NOTE no checks are made to determine if the property is readable or writable.
*
* @param target Target
* @param source Source
* @return target
*
* @example
* <listing version="3.0">
* var source:Object = { a: 1, d: 4 };
* var target:Object = { a: 0, b: 2, c: 3 }
* var result:Object = merge(target, source);
* trace(result.a, result.b, result.c, result.d);
* // 1 2 3 4
* </listing>
*
* @author drewbourne
*/
public function merge(target:Object, source:Object):Object
{
for (var field:Object in source || {})
{
target[field] = source[field];
}
return target;
}
}