-
-
Notifications
You must be signed in to change notification settings - Fork 771
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal: extract sinon type checking into own module
- Loading branch information
Showing
6 changed files
with
33 additions
and
6 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,22 @@ | ||
"use strict"; | ||
|
||
const sinonTypeSymbolProperty = Symbol("SinonType"); | ||
|
||
module.exports = { | ||
/** | ||
* Set the type of a Sinon object to make it possible to identify it later at runtime | ||
* | ||
* @param {object|Function} object object/function to set the type on | ||
* @param {string} type the named type of the object/function | ||
*/ | ||
set(object, type) { | ||
Object.defineProperty(object, sinonTypeSymbolProperty, { | ||
value: type, | ||
configurable: false, | ||
enumerable: false, | ||
}); | ||
}, | ||
get(object) { | ||
return object && object[sinonTypeSymbolProperty]; | ||
}, | ||
}; |
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