UNPKG

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