Sha256: 8d7257e620622a2fb0b571c8753da28caa4a93050e239c298154820eeac30a82

Contents?: true

Size: 918 Bytes

Versions: 23

Compression:

Stored size: 918 Bytes

Contents

'use strict'

var xtend = require('xtend')
var escapes = require('markdown-escapes')
var defaults = require('./defaults')

module.exports = setOptions

function setOptions(options) {
  var self = this
  var current = self.options
  var key
  var value

  if (options == null) {
    options = {}
  } else if (typeof options === 'object') {
    options = xtend(options)
  } else {
    throw new Error('Invalid value `' + options + '` for setting `options`')
  }

  for (key in defaults) {
    value = options[key]

    if (value == null) {
      value = current[key]
    }

    if (
      (key !== 'blocks' && typeof value !== 'boolean') ||
      (key === 'blocks' && typeof value !== 'object')
    ) {
      throw new Error(
        'Invalid value `' + value + '` for setting `options.' + key + '`'
      )
    }

    options[key] = value
  }

  self.options = options
  self.escape = escapes(options)

  return self
}

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
trusty-cms-5.0.7 node_modules/remark-parse/lib/set-options.js
trusty-cms-5.0.6 node_modules/remark-parse/lib/set-options.js
trusty-cms-5.0.5 node_modules/remark-parse/lib/set-options.js
trusty-cms-5.0.4 node_modules/remark-parse/lib/set-options.js
trusty-cms-5.0.3 node_modules/remark-parse/lib/set-options.js
trusty-cms-5.0.2 node_modules/remark-parse/lib/set-options.js
trusty-cms-5.0.1 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.3.5 node_modules/remark-parse/lib/set-options.js
trusty-cms-5.0.0 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.3.4 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.3.3 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.3.2 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.3.1 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.3 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.2.3 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.2.2 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.2.1 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.2 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.1.9 node_modules/remark-parse/lib/set-options.js
trusty-cms-4.1.8 node_modules/remark-parse/lib/set-options.js