FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
promisify-node/utils/cloneFunction.js at master · nodegit/promisify-node · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
nodegit
/
promisify-node
Public
Notifications
You must be signed in to change notification settings
Fork
19
Star
147
Code
Issues
8
Pull requests
1
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
promisify-node
/
utils
/
cloneFunction.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
17 lines (17 loc) · 678 Bytes
Breadcrumbs
promisify-node
/
utils
/
cloneFunction.js
Copy path
File metadata and controls
17 lines (17 loc) · 678 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL