You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.7 KiB

5 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var defaults = {
  4. parser: require("../parsers/esprima"),
  5. tabWidth: 4,
  6. useTabs: false,
  7. reuseWhitespace: true,
  8. lineTerminator: require("os").EOL || "\n",
  9. wrapColumn: 74,
  10. sourceFileName: null,
  11. sourceMapName: null,
  12. sourceRoot: null,
  13. inputSourceMap: null,
  14. range: false,
  15. tolerant: true,
  16. quote: null,
  17. trailingComma: false,
  18. arrayBracketSpacing: false,
  19. objectCurlySpacing: true,
  20. arrowParensAlways: false,
  21. flowObjectCommas: true,
  22. tokens: true
  23. }, hasOwn = defaults.hasOwnProperty;
  24. // Copy options and fill in default values.
  25. function normalize(opts) {
  26. var options = opts || defaults;
  27. function get(key) {
  28. return hasOwn.call(options, key)
  29. ? options[key]
  30. : defaults[key];
  31. }
  32. return {
  33. tabWidth: +get("tabWidth"),
  34. useTabs: !!get("useTabs"),
  35. reuseWhitespace: !!get("reuseWhitespace"),
  36. lineTerminator: get("lineTerminator"),
  37. wrapColumn: Math.max(get("wrapColumn"), 0),
  38. sourceFileName: get("sourceFileName"),
  39. sourceMapName: get("sourceMapName"),
  40. sourceRoot: get("sourceRoot"),
  41. inputSourceMap: get("inputSourceMap"),
  42. parser: get("esprima") || get("parser"),
  43. range: get("range"),
  44. tolerant: get("tolerant"),
  45. quote: get("quote"),
  46. trailingComma: get("trailingComma"),
  47. arrayBracketSpacing: get("arrayBracketSpacing"),
  48. objectCurlySpacing: get("objectCurlySpacing"),
  49. arrowParensAlways: get("arrowParensAlways"),
  50. flowObjectCommas: get("flowObjectCommas"),
  51. tokens: !!get("tokens")
  52. };
  53. }
  54. exports.normalize = normalize;
  55. ;