Skip to content

Commit 04e36b5

Browse files
committed
rebuild: add Set and Map support to Oblect.clone()
1 parent 678f9d7 commit 04e36b5

File tree

7 files changed

+7146
-3984
lines changed

7 files changed

+7146
-3984
lines changed

dist/super.es.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ var PrimitiveType = {
1818
var InstanceType = {
1919
OBJECT: Object,
2020
ARRAY: Array,
21+
SET: Set,
22+
MAP: Map,
2123
REGEXP: RegExp,
2224
DATE: Date
2325
};
@@ -3085,25 +3087,45 @@ var _Object = function (_extendableBuiltin2) {
30853087
return copy;
30863088
}
30873089

3090+
if (item instanceof InstanceType.SET) {
3091+
var _copy = new Set();
3092+
3093+
item.forEach(function (v) {
3094+
return _copy.add(_clone(v));
3095+
});
3096+
3097+
return _copy;
3098+
}
3099+
3100+
if (item instanceof InstanceType.MAP) {
3101+
var _copy2 = new Map();
3102+
3103+
item.forEach(function (v, k) {
3104+
return _copy2.set(k, _clone(v));
3105+
});
3106+
3107+
return _copy2;
3108+
}
3109+
30883110
if (item instanceof InstanceType.OBJECT) {
3089-
var _copy = {};
3111+
var _copy3 = {};
30903112

30913113
// $FlowFixMe
30923114
Object.getOwnPropertySymbols(item).forEach(function (s) {
3093-
return _copy[s] = _clone(item[s]);
3115+
return _copy3[s] = _clone(item[s]);
30943116
});
30953117

30963118
if (includeNonEnumerable) {
30973119
Object.getOwnPropertyNames(item).forEach(function (k) {
3098-
return _copy[k] = _clone(item[k]);
3120+
return _copy3[k] = _clone(item[k]);
30993121
});
31003122
} else {
31013123
Object.keys(item).forEach(function (k) {
3102-
return _copy[k] = _clone(item[k]);
3124+
return _copy3[k] = _clone(item[k]);
31033125
});
31043126
}
31053127

3106-
return _copy;
3128+
return _copy3;
31073129
}
31083130

31093131
throw new Error("Unable to copy object: " + item);

dist/super.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
var InstanceType = {
2525
OBJECT: Object,
2626
ARRAY: Array,
27+
SET: Set,
28+
MAP: Map,
2729
REGEXP: RegExp,
2830
DATE: Date
2931
};
@@ -3091,25 +3093,45 @@
30913093
return copy;
30923094
}
30933095

3096+
if (item instanceof InstanceType.SET) {
3097+
var _copy = new Set();
3098+
3099+
item.forEach(function (v) {
3100+
return _copy.add(_clone(v));
3101+
});
3102+
3103+
return _copy;
3104+
}
3105+
3106+
if (item instanceof InstanceType.MAP) {
3107+
var _copy2 = new Map();
3108+
3109+
item.forEach(function (v, k) {
3110+
return _copy2.set(k, _clone(v));
3111+
});
3112+
3113+
return _copy2;
3114+
}
3115+
30943116
if (item instanceof InstanceType.OBJECT) {
3095-
var _copy = {};
3117+
var _copy3 = {};
30963118

30973119
// $FlowFixMe
30983120
Object.getOwnPropertySymbols(item).forEach(function (s) {
3099-
return _copy[s] = _clone(item[s]);
3121+
return _copy3[s] = _clone(item[s]);
31003122
});
31013123

31023124
if (includeNonEnumerable) {
31033125
Object.getOwnPropertyNames(item).forEach(function (k) {
3104-
return _copy[k] = _clone(item[k]);
3126+
return _copy3[k] = _clone(item[k]);
31053127
});
31063128
} else {
31073129
Object.keys(item).forEach(function (k) {
3108-
return _copy[k] = _clone(item[k]);
3130+
return _copy3[k] = _clone(item[k]);
31093131
});
31103132
}
31113133

3112-
return _copy;
3134+
return _copy3;
31133135
}
31143136

31153137
throw new Error("Unable to copy object: " + item);

dist/super.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)