Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(src): update code base with latest ES2015+ features
- Loading branch information
1 parent
f34954f
commit bdcbef0
Showing
5 changed files
with
59 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
'use strict' | ||
|
||
module.exports = function parseOptions (params) { | ||
if (typeof params.plugins === 'function') { | ||
params.plugins = params.plugins.call(this, this) | ||
function parseOptions ({ exec, parser, syntax, stringifier, plugins }) { | ||
if (typeof plugins === 'function') { | ||
plugins = plugins.call(this, this) | ||
} | ||
|
||
let plugins | ||
|
||
if (typeof params.plugins === 'undefined') plugins = [] | ||
else if (Array.isArray(params.plugins)) plugins = params.plugins | ||
else plugins = [ params.plugins ] | ||
if (typeof plugins === 'undefined') { | ||
plugins = [] | ||
} else if (!Array.isArray(plugins)) { | ||
plugins = [ plugins ] | ||
} | ||
|
||
const options = {} | ||
|
||
if (typeof params !== 'undefined') { | ||
options.parser = params.parser | ||
options.syntax = params.syntax | ||
options.stringifier = params.stringifier | ||
} | ||
|
||
const exec = params && params.exec | ||
options.parser = parser | ||
options.syntax = syntax | ||
options.stringifier = stringifier | ||
|
||
return Promise.resolve({ options: options, plugins: plugins, exec: exec }) | ||
return Promise.resolve({ options, plugins, exec }) | ||
} | ||
|
||
module.exports = parseOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters