diff options
author | Rens Baardman <git@rensbaardman.nl> | 2019-06-11 15:11:16 +0300 |
---|---|---|
committer | Rens Baardman <git@rensbaardman.nl> | 2019-06-11 16:10:52 +0300 |
commit | d3cbd02b3d9de6cbfb518c31f9c70472508912c3 (patch) | |
tree | ecd26e185f120d8d9a1b6b1dcc15f692ac1eac08 /lib | |
parent | 5bea3d816d0258e5204f1b49b08b9fb302ac53e1 (diff) |
Change line endings from carriage returns to line feedschange-carriage-returns
Diffstat (limited to 'lib')
-rw-r--r-- | lib/__get__.js | 40 | ||||
-rw-r--r-- | lib/detectStrictMode.js | 56 |
2 files changed, 48 insertions, 48 deletions
diff --git a/lib/__get__.js b/lib/__get__.js index 74e652f..cb6fe68 100644 --- a/lib/__get__.js +++ b/lib/__get__.js @@ -1,21 +1,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");
- }
-}
-
+/** + * 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__;
\ No newline at end of file diff --git a/lib/detectStrictMode.js b/lib/detectStrictMode.js index 57dc14d..30f59fd 100644 --- a/lib/detectStrictMode.js +++ b/lib/detectStrictMode.js @@ -1,28 +1,28 @@ -var multiLineComment = /^\s*\/\*.*?\*\//;
-var singleLineComment = /^\s*\/\/.*?[\r\n]/;
-var strictMode = /^\s*(?:"use strict"|'use strict')[ \t]*(?:[\r\n]|;)/;
-
-/**
- * Returns true if the source code is intended to run in strict mode. Does not detect
- * "use strict" if it occurs in a nested function.
- *
- * @param {String} src
- * @return {Boolean}
- */
-function detectStrictMode(src) {
- var singleLine;
- var multiLine;
-
- while ((singleLine = singleLineComment.test(src)) || (multiLine = multiLineComment.test(src))) {
- if (singleLine) {
- src = src.replace(singleLineComment, "");
- }
- if (multiLine) {
- src = src.replace(multiLineComment, "");
- }
- }
-
- return strictMode.test(src);
-}
-
-module.exports = detectStrictMode;
+var multiLineComment = /^\s*\/\*.*?\*\//; +var singleLineComment = /^\s*\/\/.*?[\r\n]/; +var strictMode = /^\s*(?:"use strict"|'use strict')[ \t]*(?:[\r\n]|;)/; + +/** + * Returns true if the source code is intended to run in strict mode. Does not detect + * "use strict" if it occurs in a nested function. + * + * @param {String} src + * @return {Boolean} + */ +function detectStrictMode(src) { + var singleLine; + var multiLine; + + while ((singleLine = singleLineComment.test(src)) || (multiLine = multiLineComment.test(src))) { + if (singleLine) { + src = src.replace(singleLineComment, ""); + } + if (multiLine) { + src = src.replace(multiLineComment, ""); + } + } + + return strictMode.test(src); +} + +module.exports = detectStrictMode; |