-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from jon-hall/feature/mutating-required-module…
…s-bug Add noMutate flag, which addresses #12 and adds the ability to…
- Loading branch information
Showing
7 changed files
with
199 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module.exports = function(d, cb) { setTimeout(cb, d); }; | ||
module.exports.x = function(d, cb) { setTimeout(cb, d); }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function A(d) { this.d = d; } | ||
A.prototype.a = function(cb) { setTimeout(cb, this.d); }; | ||
module.exports = A; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Clones a function, including copying any properties of the function to the clone. | ||
* | ||
* @param {Function} func - The function to clone. | ||
*/ | ||
module.exports = function cloneFn(func) { | ||
var temp; | ||
// Check for the memoized value on the function in-case we get called to wrap the same function | ||
// (or already wrapped function) again. | ||
return func.__cloneFn || (temp = function() { | ||
return func.apply(this, arguments); | ||
}) && | ||
// Assign __proto__ as a quick way to copy function properties. | ||
(temp.__proto__ = func) && | ||
// Lastly, set a cache var on the original and clone, and return the result. | ||
(func.__cloneFn = temp.__cloneFn = temp); | ||
}; |