locutus
Version:
Locutus other languages' standard libraries to JavaScript for fun and educational purposes
19 lines (18 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.call_user_func = call_user_func;
const call_user_func_array_ts_1 = require("../funchand/call_user_func_array.js");
function call_user_func(cb, ...parameters) {
// discuss at: https://locutus.io/php/call_user_func/
// original by: Brett Zamir (https://brett-zamir.me)
// improved by: Diplom@t (https://difane.com/)
// improved by: Brett Zamir (https://brett-zamir.me)
// note 1: Depends on call_user_func_array which in turn depends on the `cb` that is passed,
// note 1: this function can use `eval`.
// note 1: The `eval` input is however checked to only allow valid function names,
// note 1: So it should not be unsafer than uses without eval (seeing as you can)
// note 1: already pass any function to be executed here.
// example 1: call_user_func('isNaN', 'a')
// returns 1: true
return (0, call_user_func_array_ts_1.call_user_func_array)(cb, parameters);
}