forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCircularUtil.js
More file actions
50 lines (44 loc) · 1.39 KB
/
Copy pathCircularUtil.js
File metadata and controls
50 lines (44 loc) · 1.39 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const CircularUtil = {
lastSeqID: 0,
parentUtil: null,
setRelativeParentUtil: function (util) {
CircularUtil.parentUtil = util;
},
createUniqueID: function (prefix) {
return createUniqueID(prefix, CircularUtil.parentUtil || CircularUtil);
},
extend: function (destination, source) {
destination = destination || {};
if (source) {
for (var property in source) {
var value = source[property];
if (value !== undefined) {
destination[property] = value;
}
}
/**
* IE doesn't include the toString property when iterating over an object's
* properties with the for(property in object) syntax. Explicitly check if
* the source has its own toString property.
*/
/*
* FF/Windows < 2.0.0.13 reports "Illegal operation on WrappedNative
* prototype object" when calling hawOwnProperty if the source object
* is an instance of window.Event.
*/
var sourceIsEvt = typeof window.Event === 'function' && source instanceof window.Event;
if (!sourceIsEvt && source.hasOwnProperty && source.hasOwnProperty('toString')) {
destination.toString = source.toString;
}
}
return destination;
}
};
function createUniqueID(prefix, util) {
if (prefix == null) {
prefix = 'id_';
}
util.lastSeqID += 1;
return prefix + util.lastSeqID;
}
export { CircularUtil };