15 lines
439 B
JavaScript
15 lines
439 B
JavaScript
|
|
function codegenNativeCommands(options) {
|
||
|
|
const commands = {};
|
||
|
|
if (options && options.supportedCommands) {
|
||
|
|
options.supportedCommands.forEach((commandName) => {
|
||
|
|
commands[commandName] = (ref, ...args) => {
|
||
|
|
if (ref && ref.current && typeof ref.current[commandName] === 'function') {
|
||
|
|
ref.current[commandName](...args);
|
||
|
|
}
|
||
|
|
};
|
||
|
|
});
|
||
|
|
}
|
||
|
|
return commands;
|
||
|
|
}
|
||
|
|
|
||
|
|
module.exports = codegenNativeCommands;
|