covutils
Version:
Utilities for creating, transforming, and handling Coverage Data objects.
25 lines (24 loc) • 484 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shallowcopy = shallowcopy;
/**
* Shallow clone a given object.
*
* Note: This does *not* handle all kinds of objects!
*
* @ignore
*/
function shallowcopy(obj) {
var copy = void 0;
if (obj instanceof Map) {
copy = new Map(obj);
} else {
copy = Object.create(Object.getPrototypeOf(obj));
for (var prop in obj) {
copy[prop] = obj[prop];
}
}
return copy;
}