]> gerrit.simantics Code Review - simantics/district.git/blob - 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
1 'use strict';
2
3 var forEach       = require('./for-each')
4   , isPlainObject = require('./is-plain-object')
5   , value         = require('./valid-value')
6
7   , isArray = Array.isArray
8   , copy, copyItem;
9
10 copyItem = function (value, key) {
11         var index;
12         if (!isPlainObject(value) && !isArray(value)) return value;
13         index = this[0].indexOf(value);
14         if (index === -1) return copy.call(this, value);
15         return this[1][index];
16 };
17
18 copy = function (source) {
19         var target = isArray(source) ? [] : {};
20         this[0].push(source);
21         this[1].push(target);
22         if (isArray(source)) {
23                 source.forEach(function (value, key) {
24                         target[key] = copyItem.call(this, value, key);
25                 }, this);
26         } else {
27                 forEach(source, function (value, key) {
28                         target[key] = copyItem.call(this, value, key);
29                 }, this);
30         }
31         return target;
32 };
33
34 module.exports = function (source) {
35         var obj = Object(value(source));
36         if (obj !== source) return obj;
37         return copy.call([[], []], obj);
38 };