UNPKG

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