mirror of
https://github.com/status-im/consul.git
synced 2025-01-17 09:11:28 +00:00
61d7acd51f
* ui: Correct some meta info * Encoder doesn't take an argument whereas decoder does * Math.trunc looks like the closest to parseInt but using the correct type * use a dynamic string when setting things on window
18 lines
449 B
JavaScript
18 lines
449 B
JavaScript
/**
|
|
* Promise aware conditional function call
|
|
*
|
|
* @param {function} cb - The function to possibily call
|
|
* @param {Promise} [what] - A boolean resolving promise
|
|
* @returns {function} - function when called returns a Promise that resolves the argument it is called with
|
|
*/
|
|
export default function(cb, what) {
|
|
return function(res) {
|
|
return what.then(function(bool) {
|
|
if (bool) {
|
|
cb();
|
|
}
|
|
return res;
|
|
});
|
|
};
|
|
}
|