flow.js 719 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. 'use strict';
  8. const flowParser = require('flow-parser');
  9. const defaultOptions = {
  10. esproposal_class_instance_fields: true,
  11. esproposal_class_static_fields: true,
  12. esproposal_decorators: true,
  13. esproposal_export_star_as: true,
  14. esproposal_optional_chaining: true,
  15. esproposal_nullish_coalescing: true,
  16. tokens: true,
  17. types: true,
  18. };
  19. /**
  20. * Wrapper to set default options
  21. */
  22. module.exports = function(options=defaultOptions) {
  23. return {
  24. parse(code) {
  25. return flowParser.parse(code, options);
  26. },
  27. };
  28. };