How to use the @canopycanopycanopy/b-ber-shapes-directives.DRAFT_DIRECTIVES.indexOf function in @canopycanopycanopy/b-ber-shapes-directives

To help you get started, we’ve selected a few @canopycanopycanopy/b-ber-shapes-directives examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github triplecanopy / b-ber / packages / b-ber-grammar-attributes / src / index.js View on Github external
const attributesObject = (attrs, _genus, context = {}) => {
  const { fileName, lineNumber } = context
  const attrsObject = {}

  let genus = _genus

  if (!genus || typeof genus !== 'string') {
    log.error(`No directive provided: ${fileName}:${lineNumber}`)
  }

  if (ALL_DIRECTIVES.indexOf(genus) < 0) {
    log.error(`Invalid directive: [${genus}] at ${fileName}:${lineNumber}`)
  }

  if (DRAFT_DIRECTIVES.indexOf(genus) > -1) {
    log.warn(`render [epub:${genus}] is [draft]. substituting with [chapter]`)
    genus = 'chapter'
  }

  if (DEPRECATED_DIRECTIVES.indexOf(genus) > -1) {
    log.warn(
      `render [epub:${genus}] is [deprecated]. substituting with [chapter]`
    )
    genus = 'chapter'
  }

  if (attrs && typeof attrs === 'string') {
    forOf(parseAttrs(attrs.trim()), (k, v) => {
      if (_isUnsupportedAttribute(_genus, k)) {
        return log.warn(
          `render omitting unsupported attribute [${k}] at [${fileName}:${lineNumber}]`