@modern-js/plugin 1.3.6 → 1.4.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/js/modern/farrow-pipeline/context.js +14 -75
  3. package/dist/js/modern/farrow-pipeline/index.js +0 -14
  4. package/dist/js/modern/farrow-pipeline/pipeline.js +12 -29
  5. package/dist/js/modern/manager/async.js +9 -69
  6. package/dist/js/modern/manager/runner.js +1 -9
  7. package/dist/js/modern/manager/shared.js +44 -0
  8. package/dist/js/modern/manager/sync.js +12 -77
  9. package/dist/js/modern/waterfall/async.js +1 -3
  10. package/dist/js/modern/waterfall/sync.js +1 -3
  11. package/dist/js/modern/workflow/async.js +3 -3
  12. package/dist/js/modern/workflow/parallel.js +2 -2
  13. package/dist/js/modern/workflow/sync.js +3 -3
  14. package/dist/js/node/farrow-pipeline/context.js +15 -88
  15. package/dist/js/node/farrow-pipeline/pipeline.js +10 -45
  16. package/dist/js/node/manager/async.js +12 -72
  17. package/dist/js/node/manager/runner.js +1 -9
  18. package/dist/js/node/manager/shared.js +64 -0
  19. package/dist/js/node/manager/sync.js +19 -87
  20. package/dist/js/node/waterfall/async.js +0 -2
  21. package/dist/js/node/waterfall/sync.js +0 -2
  22. package/dist/js/node/workflow/async.js +3 -3
  23. package/dist/js/node/workflow/parallel.js +2 -2
  24. package/dist/js/node/workflow/sync.js +3 -3
  25. package/dist/js/treeshaking/farrow-pipeline/context.js +14 -75
  26. package/dist/js/treeshaking/farrow-pipeline/index.js +0 -14
  27. package/dist/js/treeshaking/farrow-pipeline/pipeline.js +10 -29
  28. package/dist/js/treeshaking/manager/async.js +15 -160
  29. package/dist/js/treeshaking/manager/runner.js +1 -7
  30. package/dist/js/treeshaking/manager/shared.js +79 -0
  31. package/dist/js/treeshaking/manager/sync.js +12 -168
  32. package/dist/js/treeshaking/waterfall/async.js +1 -3
  33. package/dist/js/treeshaking/waterfall/sync.js +1 -3
  34. package/dist/js/treeshaking/workflow/async.js +6 -6
  35. package/dist/js/treeshaking/workflow/parallel.js +5 -5
  36. package/dist/js/treeshaking/workflow/sync.js +8 -28
  37. package/dist/types/farrow-pipeline/context.d.ts +5 -20
  38. package/dist/types/farrow-pipeline/index.d.ts +0 -14
  39. package/dist/types/farrow-pipeline/pipeline.d.ts +5 -14
  40. package/dist/types/manager/async.d.ts +4 -7
  41. package/dist/types/manager/shared.d.ts +12 -0
  42. package/dist/types/manager/sync.d.ts +5 -11
  43. package/dist/types/manager/types.d.ts +1 -6
  44. package/dist/types/waterfall/async.d.ts +1 -7
  45. package/dist/types/waterfall/sync.d.ts +0 -7
  46. package/dist/types/workflow/async.d.ts +1 -7
  47. package/dist/types/workflow/parallel.d.ts +2 -9
  48. package/dist/types/workflow/sync.d.ts +1 -10
  49. package/package.json +1 -12
  50. package/dist/js/modern/farrow-pipeline/asyncHooks.node.js +0 -74
  51. package/dist/js/modern/farrow-pipeline/asyncHooksInterface.js +0 -12
  52. package/dist/js/modern/farrow-pipeline/hook.js +0 -42
  53. package/dist/js/node/farrow-pipeline/asyncHooks.node.js +0 -93
  54. package/dist/js/node/farrow-pipeline/asyncHooksInterface.js +0 -26
  55. package/dist/js/node/farrow-pipeline/hook.js +0 -52
  56. package/dist/js/treeshaking/farrow-pipeline/asyncHooks.node.js +0 -74
  57. package/dist/js/treeshaking/farrow-pipeline/asyncHooksInterface.js +0 -12
  58. package/dist/js/treeshaking/farrow-pipeline/hook.js +0 -46
  59. package/dist/types/farrow-pipeline/asyncHooks.node.d.ts +0 -2
  60. package/dist/types/farrow-pipeline/asyncHooksInterface.d.ts +0 -19
  61. package/dist/types/farrow-pipeline/hook.d.ts +0 -9
@@ -23,10 +23,10 @@ const createWorkflow = () => {
23
23
  return workflow;
24
24
  };
25
25
 
26
- const run = async (input, options) => {
27
- const result = pipeline.run(input, _objectSpread(_objectSpread({}, options), {}, {
26
+ const run = input => {
27
+ const result = pipeline.run(input, {
28
28
  onLast: () => []
29
- }));
29
+ });
30
30
  return result.filter(Boolean);
31
31
  };
32
32
 
@@ -1,103 +1,42 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
-
3
1
  /**
4
2
  * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
5
3
  * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
6
4
  */
7
- import { createHooks } from "./hook";
8
- var ContextSymbol = Symbol["for"]('MODERN_CONTEXT');
9
5
  export var createContext = function createContext(value) {
10
- var id = Symbol('MODERN_CONTEXT_ID');
6
+ var currentValue;
11
7
 
12
8
  var create = function create(value) {
13
- var _Context;
9
+ currentValue = value;
14
10
 
15
11
  var use = function use() {
16
- var container = useContainer();
17
- return Object.seal({
12
+ return {
18
13
  get value() {
19
- return container.read(Context);
14
+ return currentValue;
20
15
  },
21
16
 
22
17
  set value(v) {
23
- container.write(Context, v);
18
+ currentValue = v;
24
19
  }
25
20
 
26
- });
21
+ };
27
22
  };
28
23
 
29
24
  var get = function get() {
30
- var container = useContainer();
31
- return container.read(Context);
25
+ return currentValue;
32
26
  };
33
27
 
34
28
  var set = function set(v) {
35
- var container = useContainer();
36
- container.write(Context, v);
29
+ currentValue = v;
37
30
  };
38
31
 
39
- var Context = (_Context = {
40
- id: id
41
- }, _defineProperty(_Context, ContextSymbol, value), _defineProperty(_Context, "create", create), _defineProperty(_Context, "use", use), _defineProperty(_Context, "get", get), _defineProperty(_Context, "set", set), _Context);
32
+ var Context = {
33
+ create: create,
34
+ use: use,
35
+ get: get,
36
+ set: set
37
+ };
42
38
  return Context;
43
39
  };
44
40
 
45
41
  return create(value);
46
- };
47
-
48
- var createContextMap = function createContextMap(storage) {
49
- var contextMap = new Map();
50
- var contexts = Object.values(storage); // eslint-disable-next-line @typescript-eslint/prefer-for-of
51
-
52
- for (var i = 0; i < contexts.length; i++) {
53
- contextMap.set(contexts[i].id, contexts[i]);
54
- }
55
-
56
- return contextMap;
57
- };
58
-
59
- export var createContainer = function createContainer() {
60
- var ContextStorage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
61
- var contextMap = createContextMap(ContextStorage);
62
-
63
- var read = function read(context) {
64
- var target = contextMap.get(context.id);
65
-
66
- if (target) {
67
- return target[ContextSymbol];
68
- }
69
-
70
- return context[ContextSymbol];
71
- };
72
-
73
- var write = function write(context, value) {
74
- contextMap.set(context.id, context.create(value));
75
- };
76
-
77
- return Object.freeze({
78
- read: read,
79
- write: write
80
- });
81
- };
82
-
83
- var _createHooks = createHooks({
84
- useContainer: function useContainer() {
85
- throw new Error("Can't call useContainer out of scope, it should be placed on top of the function");
86
- }
87
- }),
88
- run = _createHooks.run,
89
- hooks = _createHooks.hooks;
90
-
91
- export var runHooks = run;
92
- var useContainer = hooks.useContainer;
93
- export { useContainer };
94
- export var fromContainer = function fromContainer(container) {
95
- return {
96
- useContainer: function useContainer() {
97
- return container;
98
- }
99
- };
100
- };
101
- export var runWithContainer = function runWithContainer(f, container) {
102
- return runHooks(f, fromContainer(container));
103
42
  };
@@ -1,19 +1,5 @@
1
1
  /**
2
2
  * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
3
3
  * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
4
- *
5
- * removed:
6
- * - dependencies:
7
- * - tslib
8
- * - files
9
- * - compose.ts
10
- * - methods:
11
- * - usePipeline
12
- * - assertContainer
13
- * - assertContext
14
- * - isContext
15
- * - isContainer
16
- * - pipeline.useLazy
17
- * - context.assert
18
4
  */
19
5
  export * from "./pipeline";
@@ -1,14 +1,14 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
1
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
3
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
 
5
5
  /**
6
6
  * modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
7
7
  * license at https://github.com/farrow-js/farrow/blob/master/LICENSE
8
8
  */
9
- import { createContext, createContainer, fromContainer, runHooks, useContainer, runWithContainer } from "./context";
9
+ import { createContext } from "./context";
10
10
  import { createCounter } from "./counter";
11
- export { createContext, createContainer, useContainer, runWithContainer };
11
+ export { createContext };
12
12
  export var isPipeline = function isPipeline(input) {
13
13
  return Boolean(input === null || input === void 0 ? void 0 : input[PipelineSymbol]);
14
14
  };
@@ -24,11 +24,9 @@ var getMiddleware = function getMiddleware(input) {
24
24
  throw new Error("".concat(input, " is not a Middleware"));
25
25
  };
26
26
 
27
- export var createPipeline = function createPipeline(options) {
27
+ export var createPipeline = function createPipeline() {
28
28
  var _pipeline;
29
29
 
30
- var config = _objectSpread({}, options);
31
-
32
30
  var middlewares = [];
33
31
 
34
32
  var use = function use() {
@@ -40,43 +38,28 @@ export var createPipeline = function createPipeline(options) {
40
38
  return pipeline;
41
39
  };
42
40
 
43
- var createCurrentCounter = function createCurrentCounter(hooks, onLast, onLastWithContext) {
41
+ var createCurrentCounter = function createCurrentCounter(onLast) {
44
42
  return createCounter(function (index, input, next) {
45
43
  if (index >= middlewares.length) {
46
44
  if (onLast) {
47
- if (onLastWithContext) {
48
- return runHooks(function () {
49
- return onLast(input);
50
- }, hooks);
51
- }
52
-
53
45
  return onLast(input);
54
46
  }
55
47
 
56
48
  throw new Error("Expect returning a value, but all middlewares just calling next()");
57
49
  }
58
50
 
59
- return runHooks(function () {
60
- return middlewares[index](input, next);
61
- }, hooks);
51
+ return middlewares[index](input, next);
62
52
  });
63
53
  };
64
54
 
65
- var currentContainer = createContainer(config.contexts);
66
- var currentHooks = fromContainer(currentContainer);
67
- var currentCounter = createCurrentCounter(currentHooks);
55
+ var currentCounter = createCurrentCounter();
68
56
 
69
57
  var getCounter = function getCounter(options) {
70
58
  if (!options) {
71
59
  return currentCounter;
72
60
  }
73
61
 
74
- if (options !== null && options !== void 0 && options.container) {
75
- var hooks = fromContainer(options === null || options === void 0 ? void 0 : options.container);
76
- return options !== null && options !== void 0 && options.onLast ? createCurrentCounter(hooks, options.onLast, typeof options.onLastWithContext === 'boolean' ? options.onLastWithContext : true) : createCurrentCounter(hooks);
77
- }
78
-
79
- return options !== null && options !== void 0 && options.onLast ? createCurrentCounter(currentHooks, options.onLast, typeof options.onLastWithContext === 'boolean' ? options.onLastWithContext : true) : createCurrentCounter(currentHooks);
62
+ return createCurrentCounter(options === null || options === void 0 ? void 0 : options.onLast);
80
63
  };
81
64
 
82
65
  var run = function run(input, options) {
@@ -84,9 +67,7 @@ export var createPipeline = function createPipeline(options) {
84
67
  };
85
68
 
86
69
  var middleware = function middleware(input, next) {
87
- var container = useContainer();
88
70
  return run(input, {
89
- container: container,
90
71
  onLast: next
91
72
  });
92
73
  };
@@ -94,7 +75,7 @@ export var createPipeline = function createPipeline(options) {
94
75
  var pipeline = (_pipeline = {}, _defineProperty(_pipeline, PipelineSymbol, true), _defineProperty(_pipeline, "use", use), _defineProperty(_pipeline, "run", run), _defineProperty(_pipeline, "middleware", middleware), _pipeline);
95
76
  return pipeline;
96
77
  };
97
- export var createAsyncPipeline = function createAsyncPipeline(options) {
98
- var pipeline = createPipeline(options);
78
+ export var createAsyncPipeline = function createAsyncPipeline() {
79
+ var pipeline = createPipeline();
99
80
  return _objectSpread({}, pipeline);
100
81
  };
@@ -1,11 +1,9 @@
1
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
- import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
3
1
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
4
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
5
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
6
- import { runWithContainer, createContainer } from "../farrow-pipeline";
7
- import { isObject, generateRunner, hasOwnProperty, DEFAULT_OPTIONS } from "./sync";
4
+ import { generateRunner, DEFAULT_OPTIONS } from "./sync";
8
5
  import { useRunner } from "./runner";
6
+ import { checkPlugins, isObject, hasOwnProperty, sortPlugins, includePlugin } from "./shared";
9
7
  var ASYNC_PLUGIN_SYMBOL = 'ASYNC_PLUGIN_SYMBOL';
10
8
  export var createAsyncManager = function createAsyncManager(hooks, api) {
11
9
  var index = 0;
@@ -28,7 +26,7 @@ export var createAsyncManager = function createAsyncManager(hooks, api) {
28
26
  var plugins = [];
29
27
 
30
28
  var addPlugin = function addPlugin(plugin) {
31
- if (!includeAsyncPlugin(plugins, plugin)) {
29
+ if (!includePlugin(plugins, plugin)) {
32
30
  plugins.push(_objectSpread({}, plugin));
33
31
  }
34
32
  };
@@ -89,31 +87,26 @@ export var createAsyncManager = function createAsyncManager(hooks, api) {
89
87
  plugins = [];
90
88
  };
91
89
 
92
- var currentContainer = createContainer();
93
-
94
90
  var init = /*#__PURE__*/function () {
95
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
96
- var container, sortedPlugins, mergedPluginAPI, hooksList;
91
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
92
+ var sortedPlugins, mergedPluginAPI, hooksList;
97
93
  return _regeneratorRuntime().wrap(function _callee$(_context) {
98
94
  while (1) {
99
95
  switch (_context.prev = _context.next) {
100
96
  case 0:
101
- container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
102
- sortedPlugins = sortAsyncPlugins(plugins);
97
+ sortedPlugins = sortPlugins(plugins);
103
98
  mergedPluginAPI = _objectSpread(_objectSpread({}, pluginAPI), overrideAPI);
104
- checkAsyncPlugins(sortedPlugins);
105
- _context.next = 6;
99
+ checkPlugins(sortedPlugins);
100
+ _context.next = 5;
106
101
  return Promise.all(sortedPlugins.map(function (plugin) {
107
- return runWithContainer(function () {
108
- return plugin.setup(mergedPluginAPI);
109
- }, container);
102
+ return plugin.setup(mergedPluginAPI);
110
103
  }));
111
104
 
112
- case 6:
105
+ case 5:
113
106
  hooksList = _context.sent;
114
- return _context.abrupt("return", generateRunner(hooksList, container, currentHooks));
107
+ return _context.abrupt("return", generateRunner(hooksList, currentHooks));
115
108
 
116
- case 8:
109
+ case 7:
117
110
  case "end":
118
111
  return _context.stop();
119
112
  }
@@ -121,14 +114,13 @@ export var createAsyncManager = function createAsyncManager(hooks, api) {
121
114
  }, _callee);
122
115
  }));
123
116
 
124
- return function init(_x) {
117
+ return function init() {
125
118
  return _ref.apply(this, arguments);
126
119
  };
127
120
  }();
128
121
 
129
- var run = function run(cb, options) {
130
- var container = (options === null || options === void 0 ? void 0 : options.container) || currentContainer;
131
- return runWithContainer(cb, container);
122
+ var run = function run(cb) {
123
+ return cb();
132
124
  };
133
125
 
134
126
  var manager = {
@@ -146,141 +138,4 @@ export var createAsyncManager = function createAsyncManager(hooks, api) {
146
138
  };
147
139
 
148
140
  return clone();
149
- };
150
-
151
- var includeAsyncPlugin = function includeAsyncPlugin(plugins, input) {
152
- var _iterator = _createForOfIteratorHelper(plugins),
153
- _step;
154
-
155
- try {
156
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
157
- var plugin = _step.value;
158
-
159
- if (plugin.name === input.name) {
160
- return true;
161
- }
162
- }
163
- } catch (err) {
164
- _iterator.e(err);
165
- } finally {
166
- _iterator.f();
167
- }
168
-
169
- return false;
170
- };
171
-
172
- var sortAsyncPlugins = function sortAsyncPlugins(input) {
173
- var plugins = input.slice();
174
-
175
- for (var i = 0; i < plugins.length; i++) {
176
- var plugin = plugins[i];
177
-
178
- var _iterator2 = _createForOfIteratorHelper(plugin.pre),
179
- _step2;
180
-
181
- try {
182
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
183
- var pre = _step2.value;
184
-
185
- for (var j = i + 1; j < plugins.length; j++) {
186
- if (plugins[j].name === pre) {
187
- plugins = [].concat(_toConsumableArray(plugins.slice(0, i)), [plugins[j]], _toConsumableArray(plugins.slice(i, j)), _toConsumableArray(plugins.slice(j + 1, plugins.length)));
188
- }
189
- }
190
- }
191
- } catch (err) {
192
- _iterator2.e(err);
193
- } finally {
194
- _iterator2.f();
195
- }
196
-
197
- var _iterator3 = _createForOfIteratorHelper(plugin.post),
198
- _step3;
199
-
200
- try {
201
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
202
- var post = _step3.value;
203
-
204
- for (var _j = 0; _j < i; _j++) {
205
- if (plugins[_j].name === post) {
206
- plugins = [].concat(_toConsumableArray(plugins.slice(0, _j)), _toConsumableArray(plugins.slice(_j + 1, i + 1)), [plugins[_j]], _toConsumableArray(plugins.slice(i + 1, plugins.length)));
207
- }
208
- }
209
- }
210
- } catch (err) {
211
- _iterator3.e(err);
212
- } finally {
213
- _iterator3.f();
214
- }
215
- }
216
-
217
- return plugins;
218
- };
219
-
220
- var checkAsyncPlugins = function checkAsyncPlugins(plugins) {
221
- var _iterator4 = _createForOfIteratorHelper(plugins),
222
- _step4;
223
-
224
- try {
225
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
226
- var origin = _step4.value;
227
-
228
- var _iterator5 = _createForOfIteratorHelper(origin.rivals),
229
- _step5;
230
-
231
- try {
232
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
233
- var rival = _step5.value;
234
-
235
- var _iterator7 = _createForOfIteratorHelper(plugins),
236
- _step7;
237
-
238
- try {
239
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
240
- var plugin = _step7.value;
241
-
242
- if (rival === plugin.name) {
243
- throw new Error("".concat(origin.name, " has rival ").concat(plugin.name));
244
- }
245
- }
246
- } catch (err) {
247
- _iterator7.e(err);
248
- } finally {
249
- _iterator7.f();
250
- }
251
- }
252
- } catch (err) {
253
- _iterator5.e(err);
254
- } finally {
255
- _iterator5.f();
256
- }
257
-
258
- var _iterator6 = _createForOfIteratorHelper(origin.required),
259
- _step6;
260
-
261
- try {
262
- var _loop = function _loop() {
263
- var required = _step6.value;
264
-
265
- if (!plugins.some(function (plugin) {
266
- return plugin.name === required;
267
- })) {
268
- throw new Error("The plugin: ".concat(required, " is required when plugin: ").concat(origin.name, " is exist."));
269
- }
270
- };
271
-
272
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
273
- _loop();
274
- }
275
- } catch (err) {
276
- _iterator6.e(err);
277
- } finally {
278
- _iterator6.f();
279
- }
280
- }
281
- } catch (err) {
282
- _iterator4.e(err);
283
- } finally {
284
- _iterator4.f();
285
- }
286
141
  };
@@ -1,11 +1,5 @@
1
1
  import { createContext } from "../farrow-pipeline";
2
2
  export var RunnerContext = createContext(null);
3
3
  export var useRunner = function useRunner() {
4
- var runner = RunnerContext.use().value;
5
-
6
- if (!runner) {
7
- throw new Error("Can't call useRunner out of scope, it should be placed in hooks of plugin");
8
- }
9
-
10
- return runner;
4
+ return RunnerContext.get();
11
5
  };
@@ -0,0 +1,79 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
4
+ export var checkPlugins = function checkPlugins(plugins) {
5
+ plugins.forEach(function (origin) {
6
+ origin.rivals.forEach(function (rival) {
7
+ plugins.forEach(function (plugin) {
8
+ if (rival === plugin.name) {
9
+ throw new Error("".concat(origin.name, " has rival ").concat(plugin.name));
10
+ }
11
+ });
12
+ });
13
+ origin.required.forEach(function (required) {
14
+ if (!plugins.some(function (plugin) {
15
+ return plugin.name === required;
16
+ })) {
17
+ throw new Error("The plugin: ".concat(required, " is required when plugin: ").concat(origin.name, " is exist."));
18
+ }
19
+ });
20
+ });
21
+ };
22
+ export function sortPlugins(input) {
23
+ var plugins = input.slice();
24
+
25
+ for (var i = 0; i < plugins.length; i++) {
26
+ var plugin = plugins[i];
27
+
28
+ var _iterator = _createForOfIteratorHelper(plugin.pre),
29
+ _step;
30
+
31
+ try {
32
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
33
+ var pre = _step.value;
34
+
35
+ for (var j = i + 1; j < plugins.length; j++) {
36
+ if (plugins[j].name === pre) {
37
+ plugins = [].concat(_toConsumableArray(plugins.slice(0, i)), [plugins[j]], _toConsumableArray(plugins.slice(i, j)), _toConsumableArray(plugins.slice(j + 1, plugins.length)));
38
+ }
39
+ }
40
+ }
41
+ } catch (err) {
42
+ _iterator.e(err);
43
+ } finally {
44
+ _iterator.f();
45
+ }
46
+
47
+ var _iterator2 = _createForOfIteratorHelper(plugin.post),
48
+ _step2;
49
+
50
+ try {
51
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
52
+ var post = _step2.value;
53
+
54
+ for (var _j = 0; _j < i; _j++) {
55
+ if (plugins[_j].name === post) {
56
+ plugins = [].concat(_toConsumableArray(plugins.slice(0, _j)), _toConsumableArray(plugins.slice(_j + 1, i + 1)), [plugins[_j]], _toConsumableArray(plugins.slice(i + 1, plugins.length)));
57
+ }
58
+ }
59
+ }
60
+ } catch (err) {
61
+ _iterator2.e(err);
62
+ } finally {
63
+ _iterator2.f();
64
+ }
65
+ }
66
+
67
+ return plugins;
68
+ }
69
+ export var includePlugin = function includePlugin(plugins, input) {
70
+ return plugins.some(function (plugin) {
71
+ return plugin.name === input.name;
72
+ });
73
+ };
74
+ export var isObject = function isObject(obj) {
75
+ return obj !== null && _typeof(obj) === 'object';
76
+ };
77
+ export var hasOwnProperty = function hasOwnProperty(obj, prop) {
78
+ return obj.hasOwnProperty(prop);
79
+ };