feat: 'rest' for invokeComposed
This commit is contained in:
parent
0564a65fa0
commit
e270183724
|
@ -30,6 +30,7 @@
|
|||
"lodash.flatten": "^4.4.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
"lodash.set": "^4.3.2",
|
||||
"lodash.without": "^4.4.0",
|
||||
"mkdirp": "^1.0.4",
|
||||
"webpack-virtual-modules": "^0.4.1"
|
||||
},
|
||||
|
|
|
@ -4,6 +4,7 @@ import D from 'debug';
|
|||
import flatten from 'lodash.flatten';
|
||||
import get from 'lodash.get';
|
||||
import set from 'lodash.set';
|
||||
import without from 'lodash.without';
|
||||
|
||||
import Middleware from './middleware';
|
||||
import readConfig from './read-config';
|
||||
|
@ -94,7 +95,25 @@ export default class Latus {
|
|||
if (!plugins) {
|
||||
return arg;
|
||||
}
|
||||
const fns = plugins
|
||||
let finalPlugins = [];
|
||||
const index = plugins.findIndex((plugin) => '...' === plugin);
|
||||
if (-1 !== index) {
|
||||
const before = plugins.slice(0, index);
|
||||
const after = plugins.slice(index + 1);
|
||||
const rest = without(
|
||||
this.hooks[hook].map(({plugin}) => plugin),
|
||||
...before.concat(after),
|
||||
);
|
||||
finalPlugins = [
|
||||
...before,
|
||||
...rest,
|
||||
...after,
|
||||
];
|
||||
}
|
||||
else {
|
||||
finalPlugins = plugins;
|
||||
}
|
||||
const fns = finalPlugins
|
||||
.map((plugin) => {
|
||||
const candidate = this.hooks[hook].find(({plugin: candidate}) => plugin === candidate);
|
||||
if (!candidate) {
|
||||
|
|
|
@ -4055,6 +4055,11 @@ lodash.set@^4.3.2:
|
|||
resolved "http://npm.cha0sdev/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
|
||||
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=
|
||||
|
||||
lodash.without@^4.4.0:
|
||||
version "4.4.0"
|
||||
resolved "http://npm.cha0sdev/lodash.without/-/lodash.without-4.4.0.tgz#3cd4574a00b67bae373a94b748772640507b7aac"
|
||||
integrity sha1-PNRXSgC2e643OpS3SHcmQFB7eqw=
|
||||
|
||||
lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20:
|
||||
version "4.17.20"
|
||||
resolved "http://npm.cha0sdev/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
|
||||
|
|
Loading…
Reference in New Issue
Block a user