function build_plugin_desc(spec, useopts, eraro) {
  var plugin = spec.plugin

  // Don't do much with plugin options, just ensure they are an object.
  var options =
    null == spec.options
      ? null == plugin.options
        ? {}
        : plugin.options
      : spec.options
  options = 'object' === typeof options ? options : { value$: options }

  // Start building the return value.
  var plugin_desc = {
    options: options,
    callback: spec.callback,
    history: [],
  }

  // The most common case, where the plugin is
  // specified as a string name to be required in.
  if ('string' === typeof plugin) {
    plugin_desc.name = plugin
  }

  // Define the plugin with a function, most often used for small,
  // on-the-fly plugins.
  else if ('function' === typeof plugin) {
    if ('' !== plugin.name) {
      plugin_desc.name = plugin.name
    }

    // The function has no name, so generate a name for the plugin
    else {
      var prefix = Array.isArray(useopts.prefix)
        ? useopts.prefix[0]
        : useopts.prefix
      plugin_desc.name = prefix + Nid()
    }

    plugin_desc.init = plugin
  }

  // Provide some or all of plugin definition directly.
  else if ('object' === typeof plugin) {
    plugin_desc = Object.assign({}, plugin, plugin_desc)

    var name = plugin_desc.name
    if ('string' !== typeof name) {
      name = null != plugin_desc.init ? plugin_desc.init.name : null
    }

    if (null == name) {
      throw eraro('no_name', { plugin: plugin })
    } else {
      plugin_desc.name = name
    }

    if (null != plugin_desc.init && 'function' !== typeof plugin_desc.init) {
      throw eraro('no_init_function', {
        name: name,
        plugin: plugin,
      })
    }
  }

  // Options as an argument to the _use_ function override options
  // in the plugin description object.
  plugin_desc.options = Object.assign(
    {},
    plugin_desc.options || {},
    options || {}
  )

  // Plugins can be tagged.
  // The tag can be embedded inside the name using a $ separator: _name$tag_.
  // Note: the $tag suffix is NOT considered part of the file name!

  var m = /^(.+)\$(.+)$/.exec(plugin_desc.name)
  if (m) {
    plugin_desc.name = m[1]
    plugin_desc.tag = m[2]
  }

  plugin_desc.full =
    plugin_desc.name +
    (null == plugin_desc.tag || '' == plugin_desc.tag
      ? ''
      : '$' + plugin_desc.tag)

  // Plugins must have a name.
  if (!plugin_desc.name) {
    throw eraro('no_name', plugin_desc)
  }

  return plugin_desc
}
// #### Create description object for the plugin
Create description object for the plugin
Create description object for the plugin
function build_plugin_desc(spec, useopts, eraro) {
  var plugin = spec.plugin
  var options =
    null == spec.options
      ? null == plugin.options
        ? {}
        : plugin.options
      : spec.options
  options = 'object' === typeof options ? options : { value$: options }
  var plugin_desc = {
    options: options,
    callback: spec.callback,
    history: [],
  }
  if ('string' === typeof plugin) {
    plugin_desc.name = plugin
  }
  else if ('function' === typeof plugin) {
    if ('' !== plugin.name) {
      plugin_desc.name = plugin.name
    }
    else {
      var prefix = Array.isArray(useopts.prefix)
        ? useopts.prefix[0]
        : useopts.prefix
      plugin_desc.name = prefix + Nid()
    }
    plugin_desc.init = plugin
  }
  else if ('object' === typeof plugin) {
    plugin_desc = Object.assign({}, plugin, plugin_desc)
    var name = plugin_desc.name
    if ('string' !== typeof name) {
      name = null != plugin_desc.init ? plugin_desc.init.name : null
    }
    if (null == name) {
      throw eraro('no_name', { plugin: plugin })
    } else {
      plugin_desc.name = name
    }
    if (null != plugin_desc.init && 'function' !== typeof plugin_desc.init) {
      throw eraro('no_init_function', {
        name: name,
        plugin: plugin,
      })
    }
  }
  plugin_desc.options = Object.assign(
    {},
    plugin_desc.options || {},
    options || {}
  )
  var m = /^(.+)\$(.+)$/.exec(plugin_desc.name)
  if (m) {
    plugin_desc.name = m[1]
    plugin_desc.tag = m[2]
  }
  plugin_desc.full =
    plugin_desc.name +
    (null == plugin_desc.tag || '' == plugin_desc.tag
      ? ''
      : '$' + plugin_desc.tag)
  if (!plugin_desc.name) {
    throw eraro('no_name', plugin_desc)
  }
  return plugin_desc
}
function build_plugin_desc ( spec , useopts , eraro ) { var plugin = spec . plugin var options = null == spec . options ? null == plugin . options ? { } : plugin . options : spec . options options = 'object' === typeof options ? options : { value$ : options } var plugin_desc = { options : options , callback : spec . callback , history : [ ] , } if ( 'string' === typeof plugin ) { plugin_desc . name = plugin } else if ( 'function' === typeof plugin ) { if ( '' !== plugin . name ) { plugin_desc . name = plugin . name } else { var prefix = Array . isArray ( useopts . prefix ) ? useopts . prefix [ 0 ] : useopts . prefix plugin_desc . name = prefix + Nid ( ) } plugin_desc . init = plugin } else if ( 'object' === typeof plugin ) { plugin_desc = Object . assign ( { } , plugin , plugin_desc ) var name = plugin_desc . name if ( 'string' !== typeof name ) { name = null != plugin_desc . init ? plugin_desc . init . name : null } if ( null == name ) { throw eraro ( 'no_name' , { plugin : plugin } ) } else { plugin_desc . name = name } if ( null != plugin_desc . init && 'function' !== typeof plugin_desc . init ) { throw eraro ( 'no_init_function' , { name : name , plugin : plugin , } ) } } plugin_desc . options = Object . assign ( { } , plugin_desc . options || { } , options || { } ) var m = / ^(.+)\$(.+)$ / . exec ( plugin_desc . name ) if ( m ) { plugin_desc . name = m [ 1 ] plugin_desc . tag = m [ 2 ] } plugin_desc . full = plugin_desc . name + ( null == plugin_desc . tag || '' == plugin_desc . tag ? '' : '$' + plugin_desc . tag ) if ( ! plugin_desc . name ) { throw eraro ( 'no_name' , plugin_desc ) } return plugin_desc }
Create description object for the plugin
Create description object for the plugin
// Don't do much with plugin options, just ensure they are an object. // Start building the return value. // The most common case, where the plugin is // specified as a string name to be required in. // Define the plugin with a function, most often used for small, // on-the-fly plugins. // The function has no name, so generate a name for the plugin // Provide some or all of plugin definition directly. // Options as an argument to the _use_ function override options // in the plugin description object. // Plugins can be tagged. // The tag can be embedded inside the name using a $ separator: _name$tag_. // Note: the $tag suffix is NOT considered part of the file name! // Plugins must have a name.