Skip to content

Commit b0f360a

Browse files
committed
get rid of eval in replicator
1 parent 76e3ac2 commit b0f360a

1 file changed

Lines changed: 1 addition & 11 deletions

File tree

‎src/utils/replicator/index.js‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
1-
// Inlined from https://github.com/inikulin/replicator (MIT License, Ivan Nikulin)
21
/* eslint-disable no-var */
32

43
// Const
54
var TRANSFORMED_TYPE_KEY = '@t';
65
var CIRCULAR_REF_KEY = '@r';
76
var KEY_REQUIRE_ESCAPING_RE = /^#*@(t|r)$/;
87

9-
/* eslint-disable no-eval */
10-
var GLOBAL = (function getGlobal () {
11-
// NOTE: see http://www.ecma-international.org/ecma-262/6.0/index.html#sec-performeval step 10
12-
var savedEval = eval;
13-
14-
return savedEval('this');
15-
})();
16-
/* eslint-enable no-eval */
17-
188
var TYPED_ARRAY_CTORS = {
199
'Int8Array': typeof Int8Array === 'function' ? Int8Array : void 0,
2010
'Uint8Array': typeof Uint8Array === 'function' ? Uint8Array : void 0,
@@ -382,7 +372,7 @@ var builtInTransforms = [
382372
},
383373

384374
fromSerializable: function (val) {
385-
var Ctor = GLOBAL[val.name] || Error;
375+
var Ctor = globalThis[val.name] || Error;
386376
var err = new Ctor(val.message);
387377

388378
err.stack = val.stack;

0 commit comments

Comments
 (0)