-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(serialization): normalize function stringification
A non-default option for serialization allows for the automatically stringifying javascript functions. Function.prototype.toString has changed between versions of node, so we need to normalize so as to not potentially break compatibility with earlier expectations. This should have marginal performance effects only in the case where users are actually using this functionality. NODE-1499
- Loading branch information
Showing
3 changed files
with
21 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Normalizes our expected stringified form of a function across versions of node | ||
* @param {Function} fn The function to stringify | ||
*/ | ||
function normalizedFunctionString(fn) { | ||
return fn.toString().replace('function(', 'function ('); | ||
} | ||
|
||
module.exports = { | ||
normalizedFunctionString | ||
}; |