1.0.0 • Published 3 years ago
god-stop-the-callbacks v1.0.0
god-stop-the-callbacks
god-stop-the-callbacks
or gstc for short, is a simple library that turns functions that use callbacks and don't have similar promises into a synchronous function. gstc only works with callbacks where the argument is output. And it only works with single arguments, so no (req, res) => {}
. Also the arguments are in arrays. Let's explain.
Usage
gstc's usage looks like this:
gstc(/* a really dumb developer's function */, /* what the arguments are, before the callback */, /* what the arguments are, after the callback. */)
Example
An example would be:
function usesCallbacks(num1, num2, callback) {
callback(num1 + num2);
}
console.log(gstc(usesCallbacks, [1, 2], []));
If the function looked like this: f(callback, a, b)
it would look like this:
gstc(f, [], [1, 2]);
1.0.0
3 years ago