All files / src resolve-script-object-to-string.js

100% Statements 14/14
100% Branches 10/10
100% Functions 3/3
100% Lines 14/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31          13x 13x 9x   4x       58x 41x 17x 12x   5x       41x 25x   16x 13x   3x    
import {isString, isPlainObject, isUndefined} from 'lodash'
 
export {resolveScriptObjectToString as default, resolveScriptObjectToScript}
 
function resolveScriptObjectToString(script) {
  const scriptObj = resolveScriptObjectToScript(script)
  if (isPlainObject(scriptObj)) {
    return scriptObj.script
  }
  return undefined
}
 
function resolveScriptObjectToScript(script) {
  if (isPlainObject(script)) {
    return resolvePlainObjectToScript(script)
  } else if (isString(script)) {
    return {script}
  }
  return undefined
}
 
function resolvePlainObjectToScript(script) {
  if (!isUndefined(script.script)) {
    return script
  }
  if (!isUndefined(script.default)) {
    return resolveScriptObjectToScript(script.default)
  }
  return undefined
}