Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
codeql-action/node_modules/asynckit/lib/async.js
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
34 lines (30 sloc)
599 Bytes
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
var defer = require('./defer.js'); | |
// API | |
module.exports = async; | |
/** | |
* Runs provided callback asynchronously | |
* even if callback itself is not | |
* | |
* @param {function} callback - callback to invoke | |
* @returns {function} - augmented callback | |
*/ | |
function async(callback) | |
{ | |
var isAsync = false; | |
// check if async happened | |
defer(function() { isAsync = true; }); | |
return function async_callback(err, result) | |
{ | |
if (isAsync) | |
{ | |
callback(err, result); | |
} | |
else | |
{ | |
defer(function nextTick_callback() | |
{ | |
callback(err, result); | |
}); | |
} | |
}; | |
} |