Cite/options.js

  1. import {validateOutputOptions as validate} from './validate'
  2. /**
  3. * @memberof Cite#
  4. *
  5. * @property {Cite~OutputOptions} defaultOptions - default output options
  6. */
  7. const defaultOptions = {format: 'real', type: 'json', style: 'csl', lang: 'en-US'}
  8. /**
  9. * Change the default options of a `Cite` object.
  10. *
  11. * @memberof Cite#
  12. *
  13. * @param {Cite~OutputOptions} options - The options for the output
  14. * @param {Boolean} [log=false] - Show this call in the log
  15. *
  16. * @return {Cite} The updated parent object
  17. */
  18. const options = function (options, log) {
  19. if (log) {
  20. this.save()
  21. }
  22. try {
  23. validate(options)
  24. Object.assign(this._options, options)
  25. } catch ({message}) {
  26. logger.warn('[options]', message)
  27. }
  28. return this
  29. }
  30. export { options, defaultOptions }