javascriptで関数をwrapしたいときー
例えば、非同期処理の完了を待つまでなんかしたいときとか
const wrapper = function(func) {
/*** なんか処理 ***/
let result = func();
/*** なんか処理 ***/
};
async/awaitバージョン
const wrapper = async function(func) {
/*** なんか処理 ***/
let result = await func();
/*** なんか処理 ***/
};
普通ですね
つかうときー
// 引数を取らない関数の場合
wrapper(funcA)
// 引数を取る関数の場合 ここが特殊!
wrapper(funcB.bind(null, "unko"))