diff --git a/lib/compiler/index.js b/lib/compiler/index.js index f0b02bf..03fcf32 100644 --- a/lib/compiler/index.js +++ b/lib/compiler/index.js @@ -1,6 +1,20 @@ "use strict"; -let objects = require("../utils/objects"); +function processOptions(options, defaults) { + let processedOptions = {}; + + Object.keys(options).forEach(name => { + processedOptions[name] = options[name]; + }); + + Object.keys(defaults).forEach(name => { + if (!processedOptions.hasOwnProperty(name)) { + processedOptions[name] = defaults[name]; + } + }); + + return processedOptions; +} let compiler = { /* @@ -42,8 +56,7 @@ let compiler = { compile: function(ast, passes, options) { options = options !== undefined ? options : {}; - options = objects.clone(options); - objects.defaults(options, { + options = processOptions(options, { allowedStartRules: [ast.rules[0].name], cache: false, dependencies: {},