blob: cb6fe689915c86c06a00fd5a2267c4b024873f63 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
/**
* This function will be stringified and then injected into every rewired module.
* Then you can leak private variables by calling myModule.__get__("myPrivateVar");
*
* All variables within this function are namespaced in the arguments array because every
* var declaration could possibly clash with a variable in the module scope.
*
* @param {!String} name name of the variable to retrieve
* @throws {TypeError}
* @return {*}
*/
function __get__() {
arguments.varName = arguments[0];
if (arguments.varName && typeof arguments.varName === "string") {
return eval(arguments.varName);
} else {
throw new TypeError("__get__ expects a non-empty string");
}
}
module.exports = __get__;
|