diff --git a/index.js b/index.js index 43958a9..7fa2d5d 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,9 @@ const GlTransitions = require('./glTransitions'); // Cache const loadedFonts = []; +// See #16 +const checkTransition = (transition) => assert(transition == null || typeof transition === 'object', `Invalid transition ${transition}`); + module.exports = async (config = {}) => { const { @@ -36,6 +39,8 @@ module.exports = async (config = {}) => { const audioFilePath = isGif ? undefined : audioFilePathIn; + checkTransition(defaultsIn.transition); + const defaults = { duration: 4, ...defaultsIn, @@ -107,7 +112,9 @@ module.exports = async (config = {}) => { } const clips = await pMap(clipsIn, async (clip, clipIndex) => { - const { transition: userTransition, duration: userDuration, layers } = { ...clip }; + const { transition: userTransition, duration: userDuration, layers } = clip; + + checkTransition(userTransition); const videoLayers = layers.filter((layer) => layer.type === 'video'); assert(videoLayers.length <= 1, 'Max 1 video per layer');