This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d27c4d9
commit 8e527a0
Showing
8 changed files
with
164 additions
and
153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
const ChainedMap = require('./ChainedMap'); | ||
const Orderable = require('./Orderable'); | ||
|
||
module.exports = Orderable(class extends ChainedMap { | ||
constructor(parent, name) { | ||
super(parent); | ||
this.name = name; | ||
this.extend(['init']); | ||
module.exports = Orderable( | ||
class extends ChainedMap { | ||
constructor(parent, name) { | ||
super(parent); | ||
this.name = name; | ||
this.extend(['init']); | ||
|
||
this.init((Plugin, args = []) => new Plugin(...args)); | ||
} | ||
|
||
this.init((Plugin, args = []) => new Plugin(...args)); | ||
} | ||
use(plugin, args = []) { | ||
return this.set('plugin', plugin).set('args', args); | ||
} | ||
|
||
use(plugin, args = []) { | ||
return this | ||
.set('plugin', plugin) | ||
.set('args', args); | ||
} | ||
tap(f) { | ||
this.set('args', f(this.get('args') || [])); | ||
return this; | ||
} | ||
|
||
tap(f) { | ||
this.set('args', f(this.get('args') || [])); | ||
return this; | ||
} | ||
merge(obj, omit = []) { | ||
if ('plugin' in obj) { | ||
this.set('plugin', obj.plugin); | ||
} | ||
|
||
merge(obj, omit = []) { | ||
if ('plugin' in obj) { | ||
this.set('plugin', obj.plugin); | ||
} | ||
if ('args' in obj) { | ||
this.set('args', obj.args); | ||
} | ||
|
||
if ('args' in obj) { | ||
this.set('args', obj.args); | ||
return super.merge(obj, [...omit, 'args', 'plugin']); | ||
} | ||
|
||
return super.merge(obj, [...omit, 'args', 'plugin']); | ||
} | ||
toConfig() { | ||
const init = this.get('init'); | ||
const plugin = this.get('plugin'); | ||
const constructorName = plugin.__expression | ||
? `(${plugin.__expression})` | ||
: plugin.name; | ||
|
||
toConfig() { | ||
const init = this.get('init'); | ||
const plugin = this.get('plugin'); | ||
const constructorName = plugin.__expression | ||
? `(${plugin.__expression})` | ||
: plugin.name; | ||
const config = init(this.get('plugin'), this.get('args')); | ||
|
||
const config = init(this.get('plugin'), this.get('args')); | ||
Object.defineProperties(config, { | ||
__pluginName: { value: this.name }, | ||
__pluginArgs: { value: this.get('args') }, | ||
__pluginConstructorName: { value: constructorName }, | ||
}); | ||
|
||
Object.defineProperties(config, { | ||
__pluginName: { value: this.name }, | ||
__pluginArgs: { value: this.get('args') }, | ||
__pluginConstructorName: { value: constructorName } | ||
}); | ||
|
||
return config; | ||
return config; | ||
} | ||
} | ||
}); | ||
); |
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
Oops, something went wrong.