flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
20
VISUALIZACION/node_modules/clones/LICENSE
generated
vendored
Executable file
20
VISUALIZACION/node_modules/clones/LICENSE
generated
vendored
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017- commenthol
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
89
VISUALIZACION/node_modules/clones/README.md
generated
vendored
Executable file
89
VISUALIZACION/node_modules/clones/README.md
generated
vendored
Executable file
|
|
@ -0,0 +1,89 @@
|
|||
# clones
|
||||
|
||||
[](https://www.npmjs.com/package/clones/)
|
||||
|
||||
> should deep clone everything even global objects, functions, circularities, ...
|
||||
|
||||
Companion for [safer-eval](https://github.com/commenthol/safer-eval).
|
||||
|
||||
Runs on node and in modern browsers:
|
||||
|
||||
| | Versions |
|
||||
| --- | --- |
|
||||
| **node** | ~~0.12~~, 4, 6, 8, 10, 11 |
|
||||
| **Chrome** | 55, 56, 71 |
|
||||
| **Firefox** | 45, 51, 64 |
|
||||
| **Edge** | 14, 16 |
|
||||
| **IE** | ~~11~~ |
|
||||
| **Safari** | 10 |
|
||||
| **iOS Safari** | 10 |
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
npm i -S clones
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const clones = require('clones')
|
||||
const dest = clones(source, [bind])
|
||||
```
|
||||
|
||||
**Parameters**
|
||||
|
||||
**Parameters**
|
||||
|
||||
**source**: `Object`, clone source
|
||||
|
||||
**bind**: `Object`, bind functions to this context
|
||||
|
||||
**Returns**: `Any`, deep clone of `source`
|
||||
|
||||
**Example**:
|
||||
```js
|
||||
const clones = require('clones')
|
||||
|
||||
var source = {
|
||||
obj: {a: {b: 1}},
|
||||
arr: [true, 1, {c: 'dee'}],
|
||||
fn: function () { return this.number + 12 }
|
||||
}
|
||||
// adding circularity
|
||||
source.obj.a.e = source.obj.a
|
||||
|
||||
// do the cloning (with binding a context)
|
||||
var dest = clones(source, {number: 30})
|
||||
// => { obj: { a: { b: 1, e: [Circular] }, d: 2017-02-17T21:57:44.576Z },
|
||||
// arr: [ true, 1, { c: 'dee' } ],
|
||||
// fn: [Function: fn] }
|
||||
|
||||
// checks
|
||||
assert.ok(dest !== source) // has different reference
|
||||
assert.ok(dest.obj !== source.obj) // has different reference
|
||||
assert.ok(dest.obj.a !== source.obj.a) // has different reference
|
||||
assert.ok(dest.obj.a.e !== source.obj.a.e) // different references for circularities
|
||||
assert.equal(dest.obj.d.toISOString(),
|
||||
source.obj.d.toISOString()) // has same content
|
||||
assert.ok(dest.fn !== source.fn) // has different function reference
|
||||
source.fn = source.fn.bind({number: 29}) // bind `this` for `source`
|
||||
assert.equal(dest.fn(), source.fn() + 1) // returning the same result
|
||||
```
|
||||
|
||||
### Clone prototypes or classes
|
||||
|
||||
```js
|
||||
const clones = require('clones')
|
||||
// clone built in `Array`
|
||||
const C = clones.classes(Array)
|
||||
|
||||
let c = new C(1,2,3)
|
||||
// => [1, 2, 3]
|
||||
c.reverse()
|
||||
// => [3, 2, 1]
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE)
|
||||
275
VISUALIZACION/node_modules/clones/lib/index.js
generated
vendored
Executable file
275
VISUALIZACION/node_modules/clones/lib/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,275 @@
|
|||
"use strict";
|
||||
|
||||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
||||
|
||||
/**
|
||||
* @copyright 2017- commenthol
|
||||
* @license MIT
|
||||
*/
|
||||
module.exports = clones;
|
||||
/**
|
||||
* A Deep-Clone of object `source`
|
||||
*
|
||||
* @static
|
||||
* @param {Object} source - clone source
|
||||
* @param {Object} [bind] - bind functions to this context
|
||||
* @return {Any} deep clone of `source`
|
||||
* @example
|
||||
* const clones = require('clones')
|
||||
*
|
||||
* const source = [
|
||||
* {a: {b: 1}},
|
||||
* {c: {d: 2}},
|
||||
* '3',
|
||||
* function () { return 4 }
|
||||
* ]
|
||||
* // adding circularities
|
||||
* source[0].a.e = source[0].a
|
||||
*
|
||||
* const dest = clones(source)
|
||||
* // => [{ a: { b: 1, e: [Circular] } },
|
||||
* // { c: { d: 2 } },
|
||||
* // '3',
|
||||
* // [Function] ]
|
||||
*/
|
||||
|
||||
function clones(source, bind, target) {
|
||||
var opts = {
|
||||
bind: bind,
|
||||
visited: [],
|
||||
cloned: []
|
||||
};
|
||||
return _clone(opts, source, target);
|
||||
}
|
||||
/**
|
||||
* clones prototype function / class
|
||||
* @static
|
||||
* @param {Object} source - clone source
|
||||
* @return {Any} deep clone of `source`
|
||||
* @example
|
||||
* const clones = require('clones')
|
||||
* // clone built in `Array`
|
||||
* const C = clones.classes(Array)
|
||||
*
|
||||
* let c = new C(1,2,3)
|
||||
* // => [1, 2, 3]
|
||||
* c.reverse()
|
||||
* // => [3, 2, 1]
|
||||
*/
|
||||
|
||||
|
||||
clones.classes = function (source) {
|
||||
var target = function target(a, b, c, d, e, f, g, h, i) {
|
||||
try {
|
||||
return new (Function.prototype.bind.apply(source, [null].concat([].slice.call(arguments))))();
|
||||
} catch (e) {
|
||||
// Safari throws TypeError for typed Arrays
|
||||
return new source(a, b, c, d, e, f, g, h, i); // eslint-disable-line new-cap
|
||||
}
|
||||
};
|
||||
|
||||
return clones(source, source, target);
|
||||
};
|
||||
/**
|
||||
* Recursively clone source
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param {Object} opts - options
|
||||
* @param {Object} [opts.bind] - optional bind for function clones
|
||||
* @param {Array} opts.visited - visited references to detect circularities
|
||||
* @param {Array} opts.cloned - visited references of clones to assign circularities
|
||||
* @param {Any} source - The object to clone
|
||||
* @return {Any} deep clone of `source`
|
||||
*/
|
||||
|
||||
|
||||
function _clone(opts, source, target) {
|
||||
var type = toType(source);
|
||||
|
||||
switch (type) {
|
||||
case 'String':
|
||||
case 'Number':
|
||||
case 'Boolean':
|
||||
case 'Null':
|
||||
case 'Undefined':
|
||||
case 'Symbol':
|
||||
case 'DOMPrototype': // (browser)
|
||||
|
||||
case 'process':
|
||||
// (node) cloning this is not a good idea
|
||||
target = source;
|
||||
break;
|
||||
|
||||
case 'Function':
|
||||
if (!target) {
|
||||
var _bind = opts.bind === null ? null : opts.bind || source;
|
||||
|
||||
if (opts.wrapFn) {
|
||||
target = function target() {
|
||||
return source.apply(_bind, arguments);
|
||||
};
|
||||
} else {
|
||||
target = source.bind(_bind);
|
||||
}
|
||||
}
|
||||
|
||||
target = _props(opts, source, target);
|
||||
break;
|
||||
|
||||
case 'Int8Array':
|
||||
case 'Uint8Array':
|
||||
case 'Uint8ClampedArray':
|
||||
case 'Int16Array':
|
||||
case 'Uint16Array':
|
||||
case 'Int32Array':
|
||||
case 'Uint32Array':
|
||||
case 'Float32Array':
|
||||
case 'Float64Array':
|
||||
target = new source.constructor(source);
|
||||
break;
|
||||
|
||||
case 'Array':
|
||||
target = source.map(function (item) {
|
||||
return _clone(opts, item);
|
||||
});
|
||||
target = _props(opts, source, target);
|
||||
break;
|
||||
|
||||
case 'Date':
|
||||
target = new Date(source);
|
||||
break;
|
||||
|
||||
case 'Error':
|
||||
case 'EvalError':
|
||||
case 'InternalError':
|
||||
case 'RangeError':
|
||||
case 'ReferenceError':
|
||||
case 'SyntaxError':
|
||||
case 'TypeError':
|
||||
case 'URIError':
|
||||
target = new source.constructor(source.message);
|
||||
target = _props(opts, source, target);
|
||||
target.stack = source.stack;
|
||||
break;
|
||||
|
||||
case 'RegExp':
|
||||
var flags = source.flags || (source.global ? 'g' : '') + (source.ignoreCase ? 'i' : '') + (source.multiline ? 'm' : '');
|
||||
target = new RegExp(source.source, flags);
|
||||
break;
|
||||
|
||||
case 'Buffer':
|
||||
target = new source.constructor(source);
|
||||
break;
|
||||
|
||||
case 'Window': // clone of global object
|
||||
|
||||
case 'global':
|
||||
opts.wrapFn = true;
|
||||
target = _props(opts, source, target || {});
|
||||
break;
|
||||
|
||||
case 'Math':
|
||||
case 'JSON':
|
||||
case 'Console':
|
||||
case 'Navigator':
|
||||
case 'Screen':
|
||||
case 'Object':
|
||||
target = _props(opts, source, target || {});
|
||||
break;
|
||||
|
||||
default:
|
||||
if (/^HTML/.test(type)) {
|
||||
// handle HTMLElements
|
||||
if (source.cloneNode) {
|
||||
target = source.cloneNode(true);
|
||||
} else {
|
||||
target = source;
|
||||
}
|
||||
} else if (_typeof(source) === 'object') {
|
||||
// handle other object based types
|
||||
target = _props(opts, source, target || {});
|
||||
} else {
|
||||
// anything else should be a primitive
|
||||
target = source;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
/**
|
||||
* Clone property while cloning circularities
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param {Object} opts - options
|
||||
* @param {Any} source - source object
|
||||
* @param {Any} [target] - target object
|
||||
* @returns {Any} target
|
||||
*/
|
||||
|
||||
|
||||
function _props(opts, source, target) {
|
||||
var idx = opts.visited.indexOf(source); // check for circularities
|
||||
|
||||
if (idx === -1) {
|
||||
opts.visited.push(source);
|
||||
opts.cloned.push(target);
|
||||
Object.getOwnPropertyNames(source).forEach(function (key) {
|
||||
if (key === 'prototype') {
|
||||
target[key] = Object.create(source[key]);
|
||||
Object.getOwnPropertyNames(source[key]).forEach(function (p) {
|
||||
if (p !== 'constructor') {
|
||||
_descriptor(opts, source[key], target[key], p); // } else {
|
||||
// target[key][p] = target
|
||||
// Safari may throw here with TypeError: Attempted to assign to readonly property.
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
_descriptor(opts, source, target, key);
|
||||
}
|
||||
});
|
||||
opts.visited.pop();
|
||||
opts.cloned.pop();
|
||||
} else {
|
||||
target = opts.cloned[idx]; // add reference of circularity
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
/**
|
||||
* assign descriptor with property `key` from source to target
|
||||
* @private
|
||||
*/
|
||||
|
||||
|
||||
function _descriptor(opts, source, target, key) {
|
||||
var desc = Object.getOwnPropertyDescriptor(source, key);
|
||||
|
||||
if (desc) {
|
||||
if (desc.writable) {
|
||||
desc.value = _clone(opts, desc.value);
|
||||
}
|
||||
|
||||
try {
|
||||
Object.defineProperty(target, key, desc);
|
||||
} catch (e) {
|
||||
// Safari throws with TypeError:
|
||||
// Attempting to change access mechanism for an unconfigurable property.
|
||||
// Attempting to change value of a readonly property.
|
||||
if (!'Attempting to change'.indexOf(e.message)) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
||||
|
||||
function toType(o) {
|
||||
return toString.call(o).replace(/^\[[a-z]+ (.*)\]$/, '$1');
|
||||
}
|
||||
65
VISUALIZACION/node_modules/clones/package.json
generated
vendored
Executable file
65
VISUALIZACION/node_modules/clones/package.json
generated
vendored
Executable file
|
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
"name": "clones",
|
||||
"version": "1.2.0",
|
||||
"description": "should deep clone everything even global objects, functions, circularities, ...",
|
||||
"keywords": [
|
||||
"circular",
|
||||
"clone",
|
||||
"deep-clone",
|
||||
"global"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/commenthol/clones/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/commenthol/clones.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "commenthol <commenthol@gmail.com>",
|
||||
"main": "lib",
|
||||
"jsnext:main": "src",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"all": "npm run clean && npm run lint && npm run transpile && npm test",
|
||||
"clean": "rimraf lib",
|
||||
"coverage": "nyc -r html -r text npm test",
|
||||
"karma": "karma start",
|
||||
"lint": "eslint --fix \"**/*.js\"",
|
||||
"prepublishOnly": "npm run all",
|
||||
"test": "mocha",
|
||||
"transpile": "babel -d lib src",
|
||||
"zuul": "zuul --no-coverage --local 3000 -- test/*.js"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.2.3",
|
||||
"@babel/core": "^7.2.2",
|
||||
"@babel/preset-env": "^7.2.3",
|
||||
"babel-loader": "^8.0.4",
|
||||
"eslint": "^5.11.1",
|
||||
"eslint-config-standard": "^12.0.0",
|
||||
"eslint-plugin-import": "^2.14.0",
|
||||
"eslint-plugin-node": "^8.0.0",
|
||||
"eslint-plugin-promise": "^4.0.1",
|
||||
"eslint-plugin-standard": "^4.0.0",
|
||||
"karma": "^3.1.4",
|
||||
"karma-chrome-launcher": "^2.0.0",
|
||||
"karma-coverage": "^1.1.1",
|
||||
"karma-firefox-launcher": "^1.0.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-sourcemap-loader": "^0.3.7",
|
||||
"karma-spec-reporter": "~0.0.32",
|
||||
"karma-webpack": "^3.0.5",
|
||||
"mocha": "^5.2.0",
|
||||
"nyc": "^13.1.0",
|
||||
"rimraf": "^2.5.4",
|
||||
"webpack": "^4.28.3",
|
||||
"zuul": "^3.11.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
}
|
||||
244
VISUALIZACION/node_modules/clones/src/index.js
generated
vendored
Executable file
244
VISUALIZACION/node_modules/clones/src/index.js
generated
vendored
Executable file
|
|
@ -0,0 +1,244 @@
|
|||
/**
|
||||
* @copyright 2017- commenthol
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
module.exports = clones
|
||||
|
||||
/**
|
||||
* A Deep-Clone of object `source`
|
||||
*
|
||||
* @static
|
||||
* @param {Object} source - clone source
|
||||
* @param {Object} [bind] - bind functions to this context
|
||||
* @return {Any} deep clone of `source`
|
||||
* @example
|
||||
* const clones = require('clones')
|
||||
*
|
||||
* const source = [
|
||||
* {a: {b: 1}},
|
||||
* {c: {d: 2}},
|
||||
* '3',
|
||||
* function () { return 4 }
|
||||
* ]
|
||||
* // adding circularities
|
||||
* source[0].a.e = source[0].a
|
||||
*
|
||||
* const dest = clones(source)
|
||||
* // => [{ a: { b: 1, e: [Circular] } },
|
||||
* // { c: { d: 2 } },
|
||||
* // '3',
|
||||
* // [Function] ]
|
||||
*/
|
||||
function clones (source, bind, target) {
|
||||
let opts = {
|
||||
bind: bind,
|
||||
visited: [],
|
||||
cloned: []
|
||||
}
|
||||
return _clone(opts, source, target)
|
||||
}
|
||||
|
||||
/**
|
||||
* clones prototype function / class
|
||||
* @static
|
||||
* @param {Object} source - clone source
|
||||
* @return {Any} deep clone of `source`
|
||||
* @example
|
||||
* const clones = require('clones')
|
||||
* // clone built in `Array`
|
||||
* const C = clones.classes(Array)
|
||||
*
|
||||
* let c = new C(1,2,3)
|
||||
* // => [1, 2, 3]
|
||||
* c.reverse()
|
||||
* // => [3, 2, 1]
|
||||
*/
|
||||
clones.classes = function (source) {
|
||||
let target = function (a, b, c, d, e, f, g, h, i) {
|
||||
try {
|
||||
return new (Function.prototype.bind.apply(source, [null].concat([].slice.call(arguments))))()
|
||||
} catch (e) {
|
||||
// Safari throws TypeError for typed Arrays
|
||||
return new source(a, b, c, d, e, f, g, h, i) // eslint-disable-line new-cap
|
||||
}
|
||||
}
|
||||
return clones(source, source, target)
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively clone source
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param {Object} opts - options
|
||||
* @param {Object} [opts.bind] - optional bind for function clones
|
||||
* @param {Array} opts.visited - visited references to detect circularities
|
||||
* @param {Array} opts.cloned - visited references of clones to assign circularities
|
||||
* @param {Any} source - The object to clone
|
||||
* @return {Any} deep clone of `source`
|
||||
*/
|
||||
function _clone (opts, source, target) {
|
||||
let type = toType(source)
|
||||
switch (type) {
|
||||
case 'String':
|
||||
case 'Number':
|
||||
case 'Boolean':
|
||||
case 'Null':
|
||||
case 'Undefined':
|
||||
case 'Symbol':
|
||||
case 'DOMPrototype': // (browser)
|
||||
case 'process': // (node) cloning this is not a good idea
|
||||
target = source
|
||||
break
|
||||
case 'Function':
|
||||
if (!target) {
|
||||
let _bind = (opts.bind === null ? null : opts.bind || source)
|
||||
if (opts.wrapFn) {
|
||||
target = function () {
|
||||
return source.apply(_bind, arguments)
|
||||
}
|
||||
} else {
|
||||
target = source.bind(_bind)
|
||||
}
|
||||
}
|
||||
target = _props(opts, source, target)
|
||||
break
|
||||
case 'Int8Array':
|
||||
case 'Uint8Array':
|
||||
case 'Uint8ClampedArray':
|
||||
case 'Int16Array':
|
||||
case 'Uint16Array':
|
||||
case 'Int32Array':
|
||||
case 'Uint32Array':
|
||||
case 'Float32Array':
|
||||
case 'Float64Array':
|
||||
target = new source.constructor(source)
|
||||
break
|
||||
case 'Array':
|
||||
target = source.map(function (item) {
|
||||
return _clone(opts, item)
|
||||
})
|
||||
target = _props(opts, source, target)
|
||||
break
|
||||
case 'Date':
|
||||
target = new Date(source)
|
||||
break
|
||||
case 'Error':
|
||||
case 'EvalError':
|
||||
case 'InternalError':
|
||||
case 'RangeError':
|
||||
case 'ReferenceError':
|
||||
case 'SyntaxError':
|
||||
case 'TypeError':
|
||||
case 'URIError':
|
||||
target = new source.constructor(source.message)
|
||||
target = _props(opts, source, target)
|
||||
target.stack = source.stack
|
||||
break
|
||||
case 'RegExp':
|
||||
let flags = source.flags ||
|
||||
(source.global ? 'g' : '') +
|
||||
(source.ignoreCase ? 'i' : '') +
|
||||
(source.multiline ? 'm' : '')
|
||||
target = new RegExp(source.source, flags)
|
||||
break
|
||||
case 'Buffer':
|
||||
target = new source.constructor(source)
|
||||
break
|
||||
case 'Window': // clone of global object
|
||||
case 'global':
|
||||
opts.wrapFn = true
|
||||
target = _props(opts, source, target || {})
|
||||
break
|
||||
case 'Math':
|
||||
case 'JSON':
|
||||
case 'Console':
|
||||
case 'Navigator':
|
||||
case 'Screen':
|
||||
case 'Object':
|
||||
target = _props(opts, source, target || {})
|
||||
break
|
||||
default:
|
||||
if (/^HTML/.test(type)) { // handle HTMLElements
|
||||
if (source.cloneNode) {
|
||||
target = source.cloneNode(true)
|
||||
} else {
|
||||
target = source
|
||||
}
|
||||
} else if (typeof source === 'object') { // handle other object based types
|
||||
target = _props(opts, source, target || {})
|
||||
} else { // anything else should be a primitive
|
||||
target = source
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone property while cloning circularities
|
||||
*
|
||||
* @static
|
||||
* @private
|
||||
* @param {Object} opts - options
|
||||
* @param {Any} source - source object
|
||||
* @param {Any} [target] - target object
|
||||
* @returns {Any} target
|
||||
*/
|
||||
function _props (opts, source, target) {
|
||||
let idx = opts.visited.indexOf(source) // check for circularities
|
||||
if (idx === -1) {
|
||||
opts.visited.push(source)
|
||||
opts.cloned.push(target)
|
||||
Object.getOwnPropertyNames(source).forEach(function (key) {
|
||||
if (key === 'prototype') {
|
||||
target[key] = Object.create(source[key])
|
||||
Object.getOwnPropertyNames(source[key]).forEach(function (p) {
|
||||
if (p !== 'constructor') {
|
||||
_descriptor(opts, source[key], target[key], p)
|
||||
// } else {
|
||||
// target[key][p] = target
|
||||
// Safari may throw here with TypeError: Attempted to assign to readonly property.
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_descriptor(opts, source, target, key)
|
||||
}
|
||||
})
|
||||
opts.visited.pop()
|
||||
opts.cloned.pop()
|
||||
} else {
|
||||
target = opts.cloned[idx] // add reference of circularity
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
/**
|
||||
* assign descriptor with property `key` from source to target
|
||||
* @private
|
||||
*/
|
||||
function _descriptor (opts, source, target, key) {
|
||||
let desc = Object.getOwnPropertyDescriptor(source, key)
|
||||
if (desc) {
|
||||
if (desc.writable) {
|
||||
desc.value = _clone(opts, desc.value)
|
||||
}
|
||||
try {
|
||||
Object.defineProperty(target, key, desc)
|
||||
} catch (e) {
|
||||
// Safari throws with TypeError:
|
||||
// Attempting to change access mechanism for an unconfigurable property.
|
||||
// Attempting to change value of a readonly property.
|
||||
if (!'Attempting to change'.indexOf(e.message)) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function toType (o) {
|
||||
return toString.call(o).replace(/^\[[a-z]+ (.*)\]$/, '$1')
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue