react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / node_modules / commoner / node_modules / recast / lib / options.js
81169 viewsvar defaults = {1// If you want to use a different branch of esprima, or any other2// module that supports a .parse function, pass that module object to3// recast.parse as options.esprima.4esprima: require("esprima-fb"),56// Number of spaces the pretty-printer should use per tab for7// indentation. If you do not pass this option explicitly, it will be8// (quite reliably!) inferred from the original code.9tabWidth: 4,1011// If you really want the pretty-printer to use tabs instead of12// spaces, make this option true.13useTabs: false,1415// The reprinting code leaves leading whitespace untouched unless it16// has to reindent a line, or you pass false for this option.17reuseWhitespace: true,1819// Some of the pretty-printer code (such as that for printing function20// parameter lists) makes a valiant attempt to prevent really long21// lines. You can adjust the limit by changing this option; however,22// there is no guarantee that line length will fit inside this limit.23wrapColumn: 74, // Aspirational for now.2425// Pass a string as options.sourceFileName to recast.parse to tell the26// reprinter to keep track of reused code so that it can construct a27// source map automatically.28sourceFileName: null,2930// Pass a string as options.sourceMapName to recast.print, and31// (provided you passed options.sourceFileName earlier) the32// PrintResult of recast.print will have a .map property for the33// generated source map.34sourceMapName: null,3536// If provided, this option will be passed along to the source map37// generator as a root directory for relative source file paths.38sourceRoot: null,3940// If you provide a source map that was generated from a previous call41// to recast.print as options.inputSourceMap, the old source map will42// be composed with the new source map.43inputSourceMap: null,4445// If you want esprima to generate .range information (recast only46// uses .loc internally), pass true for this option.47range: false,4849// If you want esprima not to throw exceptions when it encounters50// non-fatal errors, keep this option true.51tolerant: true,5253// If you want to override the quotes used in string literals, specify54// either "single", "double", or "auto" here ("auto" will select the one55// which results in the shorter literal)56// Otherwise, the input marks will be preserved57quote: null,58}, hasOwn = defaults.hasOwnProperty;5960// Copy options and fill in default values.61exports.normalize = function(options) {62options = options || defaults;6364function get(key) {65return hasOwn.call(options, key)66? options[key]67: defaults[key];68}6970return {71tabWidth: +get("tabWidth"),72useTabs: !!get("useTabs"),73reuseWhitespace: !!get("reuseWhitespace"),74wrapColumn: Math.max(get("wrapColumn"), 0),75sourceFileName: get("sourceFileName"),76sourceMapName: get("sourceMapName"),77sourceRoot: get("sourceRoot"),78inputSourceMap: get("inputSourceMap"),79esprima: get("esprima"),80range: get("range"),81tolerant: get("tolerant"),82quote: get("quote"),83};84};858687