wavesurfer-react
Version:
react wrapper for wavesurfer.js
13 lines (11 loc) • 564 B
JavaScript
function createPlugin(pluginObj) {
const { plugin, options, creator = 'create' } = pluginObj;
const createMethod = plugin[creator];
if (!plugin) throw new Error(`Please pass a valid plugin in plugin list`);
if (!creator) throw new Error(`Please pass the creator function name in 'creator' property.`);
if (typeof createMethod !== 'function') {
throw new Error(`"${creator}" is not callable on given plugin. Please pass a valid 'creator' in plugins list.`);
}
return createMethod(options);
}
export { createPlugin as default };