]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/copy-deep.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / node-gyp / node_modules / path-array / node_modules / array-index / node_modules / es6-symbol / node_modules / es5-ext / object / copy-deep.js
diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/copy-deep.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/copy-deep.js
new file mode 100644 (file)
index 0000000..b203a7c
--- /dev/null
@@ -0,0 +1,38 @@
+'use strict';
+
+var forEach       = require('./for-each')
+  , isPlainObject = require('./is-plain-object')
+  , value         = require('./valid-value')
+
+  , isArray = Array.isArray
+  , copy, copyItem;
+
+copyItem = function (value, key) {
+       var index;
+       if (!isPlainObject(value) && !isArray(value)) return value;
+       index = this[0].indexOf(value);
+       if (index === -1) return copy.call(this, value);
+       return this[1][index];
+};
+
+copy = function (source) {
+       var target = isArray(source) ? [] : {};
+       this[0].push(source);
+       this[1].push(target);
+       if (isArray(source)) {
+               source.forEach(function (value, key) {
+                       target[key] = copyItem.call(this, value, key);
+               }, this);
+       } else {
+               forEach(source, function (value, key) {
+                       target[key] = copyItem.call(this, value, key);
+               }, this);
+       }
+       return target;
+};
+
+module.exports = function (source) {
+       var obj = Object(value(source));
+       if (obj !== source) return obj;
+       return copy.call([[], []], obj);
+};