@modern-js/plugin 1.3.3 → 1.3.4
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.
- package/CHANGELOG.md +7 -0
- package/dist/js/modern/farrow-pipeline/asyncHooks.node.js +74 -0
- package/dist/js/modern/farrow-pipeline/asyncHooksInterface.js +12 -0
- package/dist/js/modern/farrow-pipeline/context.js +99 -0
- package/dist/js/modern/farrow-pipeline/counter.js +18 -0
- package/dist/js/modern/farrow-pipeline/hook.js +42 -0
- package/dist/js/modern/farrow-pipeline/index.js +19 -0
- package/dist/js/modern/farrow-pipeline/pipeline.js +93 -0
- package/dist/js/modern/index.js +1 -1
- package/dist/js/modern/manager/async.js +1 -1
- package/dist/js/modern/manager/runner.js +1 -1
- package/dist/js/modern/manager/sync.js +1 -1
- package/dist/js/modern/waterfall/async.js +2 -4
- package/dist/js/modern/waterfall/sync.js +2 -4
- package/dist/js/modern/workflow/async.js +1 -1
- package/dist/js/modern/workflow/parallel.js +1 -1
- package/dist/js/modern/workflow/sync.js +1 -1
- package/dist/js/node/farrow-pipeline/asyncHooks.node.js +93 -0
- package/dist/js/node/farrow-pipeline/asyncHooksInterface.js +26 -0
- package/dist/js/node/farrow-pipeline/context.js +120 -0
- package/dist/js/node/farrow-pipeline/counter.js +27 -0
- package/dist/js/node/farrow-pipeline/hook.js +52 -0
- package/dist/js/node/farrow-pipeline/index.js +18 -0
- package/dist/js/node/farrow-pipeline/pipeline.js +129 -0
- package/dist/js/node/index.js +1 -1
- package/dist/js/node/manager/async.js +1 -1
- package/dist/js/node/manager/runner.js +1 -1
- package/dist/js/node/manager/sync.js +1 -1
- package/dist/js/node/waterfall/async.js +2 -4
- package/dist/js/node/waterfall/sync.js +2 -4
- package/dist/js/node/workflow/async.js +1 -1
- package/dist/js/node/workflow/parallel.js +1 -1
- package/dist/js/node/workflow/sync.js +1 -1
- package/dist/js/treeshaking/farrow-pipeline/asyncHooks.node.js +74 -0
- package/dist/js/treeshaking/farrow-pipeline/asyncHooksInterface.js +12 -0
- package/dist/js/treeshaking/farrow-pipeline/context.js +103 -0
- package/dist/js/treeshaking/farrow-pipeline/counter.js +23 -0
- package/dist/js/treeshaking/farrow-pipeline/hook.js +46 -0
- package/dist/js/treeshaking/farrow-pipeline/index.js +19 -0
- package/dist/js/treeshaking/farrow-pipeline/pipeline.js +100 -0
- package/dist/js/treeshaking/index.js +1 -1
- package/dist/js/treeshaking/manager/async.js +5 -26
- package/dist/js/treeshaking/manager/runner.js +1 -1
- package/dist/js/treeshaking/manager/sync.js +5 -23
- package/dist/js/treeshaking/waterfall/async.js +6 -27
- package/dist/js/treeshaking/waterfall/sync.js +5 -22
- package/dist/js/treeshaking/workflow/async.js +6 -26
- package/dist/js/treeshaking/workflow/parallel.js +5 -24
- package/dist/js/treeshaking/workflow/sync.js +5 -24
- package/dist/types/farrow-pipeline/asyncHooks.node.d.ts +2 -0
- package/dist/types/farrow-pipeline/asyncHooksInterface.d.ts +19 -0
- package/dist/types/farrow-pipeline/context.d.ts +28 -0
- package/dist/types/farrow-pipeline/counter.d.ts +11 -0
- package/dist/types/farrow-pipeline/hook.d.ts +9 -0
- package/dist/types/farrow-pipeline/index.d.ts +19 -0
- package/dist/types/farrow-pipeline/pipeline.d.ts +38 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/manager/runner.d.ts +1 -1
- package/dist/types/manager/sync.d.ts +1 -1
- package/dist/types/manager/types.d.ts +1 -1
- package/dist/types/waterfall/async.d.ts +1 -1
- package/dist/types/waterfall/sync.d.ts +1 -1
- package/dist/types/workflow/async.d.ts +1 -1
- package/dist/types/workflow/sync.d.ts +1 -1
- package/package.json +36 -8
- package/.eslintrc.js +0 -8
- package/jest.config.js +0 -7
- package/modern.config.js +0 -2
- package/node.d.ts +0 -1
- package/node.js +0 -1
- package/tsconfig.json +0 -14
@@ -0,0 +1,46 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*/
|
5
|
+
import { asyncHooks } from "./asyncHooksInterface";
|
6
|
+
export var createHooks = function createHooks(defaultHooks) {
|
7
|
+
var currentHooks = {};
|
8
|
+
var hooks = {};
|
9
|
+
|
10
|
+
var _loop = function _loop(key) {
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-loop-func
|
12
|
+
var f = function f() {
|
13
|
+
var _asyncHooks$get;
|
14
|
+
|
15
|
+
var hooks = currentHooks === defaultHooks ? (_asyncHooks$get = asyncHooks === null || asyncHooks === void 0 ? void 0 : asyncHooks.get()) !== null && _asyncHooks$get !== void 0 ? _asyncHooks$get : defaultHooks : currentHooks;
|
16
|
+
var handler = hooks[key];
|
17
|
+
|
18
|
+
if (typeof handler !== 'function') {
|
19
|
+
handler = defaultHooks[key];
|
20
|
+
}
|
21
|
+
|
22
|
+
return handler.apply(void 0, arguments);
|
23
|
+
};
|
24
|
+
|
25
|
+
hooks[key] = f;
|
26
|
+
};
|
27
|
+
|
28
|
+
for (var key in defaultHooks) {
|
29
|
+
_loop(key);
|
30
|
+
}
|
31
|
+
|
32
|
+
var run = function run(f, implementations) {
|
33
|
+
try {
|
34
|
+
currentHooks = implementations || defaultHooks;
|
35
|
+
asyncHooks === null || asyncHooks === void 0 ? void 0 : asyncHooks.set(currentHooks);
|
36
|
+
return f();
|
37
|
+
} finally {
|
38
|
+
currentHooks = defaultHooks;
|
39
|
+
}
|
40
|
+
};
|
41
|
+
|
42
|
+
return {
|
43
|
+
run: run,
|
44
|
+
hooks: hooks
|
45
|
+
};
|
46
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
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
|
+
*/
|
19
|
+
export * from "./pipeline";
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
7
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
8
|
+
*/
|
9
|
+
import { createContext, createContainer, fromContainer, runHooks, useContainer, runWithContainer } from "./context";
|
10
|
+
import { createCounter } from "./counter";
|
11
|
+
export { createContext, createContainer, useContainer, runWithContainer };
|
12
|
+
export var isPipeline = function isPipeline(input) {
|
13
|
+
return Boolean(input === null || input === void 0 ? void 0 : input[PipelineSymbol]);
|
14
|
+
};
|
15
|
+
var PipelineSymbol = Symbol('pipeline');
|
16
|
+
|
17
|
+
var getMiddleware = function getMiddleware(input) {
|
18
|
+
if (typeof input === 'function') {
|
19
|
+
return input;
|
20
|
+
} else if (input && typeof input.middleware === 'function') {
|
21
|
+
return input.middleware;
|
22
|
+
}
|
23
|
+
|
24
|
+
throw new Error("".concat(input, " is not a Middleware"));
|
25
|
+
};
|
26
|
+
|
27
|
+
export var createPipeline = function createPipeline(options) {
|
28
|
+
var _pipeline;
|
29
|
+
|
30
|
+
var config = _objectSpread({}, options);
|
31
|
+
|
32
|
+
var middlewares = [];
|
33
|
+
|
34
|
+
var use = function use() {
|
35
|
+
for (var _len = arguments.length, inputs = new Array(_len), _key = 0; _key < _len; _key++) {
|
36
|
+
inputs[_key] = arguments[_key];
|
37
|
+
}
|
38
|
+
|
39
|
+
middlewares.push.apply(middlewares, _toConsumableArray(inputs.map(getMiddleware)));
|
40
|
+
return pipeline;
|
41
|
+
};
|
42
|
+
|
43
|
+
var createCurrentCounter = function createCurrentCounter(hooks, onLast, onLastWithContext) {
|
44
|
+
return createCounter(function (index, input, next) {
|
45
|
+
if (index >= middlewares.length) {
|
46
|
+
if (onLast) {
|
47
|
+
if (onLastWithContext) {
|
48
|
+
return runHooks(function () {
|
49
|
+
return onLast(input);
|
50
|
+
}, hooks);
|
51
|
+
}
|
52
|
+
|
53
|
+
return onLast(input);
|
54
|
+
}
|
55
|
+
|
56
|
+
throw new Error("Expect returning a value, but all middlewares just calling next()");
|
57
|
+
}
|
58
|
+
|
59
|
+
return runHooks(function () {
|
60
|
+
return middlewares[index](input, next);
|
61
|
+
}, hooks);
|
62
|
+
});
|
63
|
+
};
|
64
|
+
|
65
|
+
var currentContainer = createContainer(config.contexts);
|
66
|
+
var currentHooks = fromContainer(currentContainer);
|
67
|
+
var currentCounter = createCurrentCounter(currentHooks);
|
68
|
+
|
69
|
+
var getCounter = function getCounter(options) {
|
70
|
+
if (!options) {
|
71
|
+
return currentCounter;
|
72
|
+
}
|
73
|
+
|
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);
|
80
|
+
};
|
81
|
+
|
82
|
+
var run = function run(input, options) {
|
83
|
+
return getCounter(options).start(input);
|
84
|
+
};
|
85
|
+
|
86
|
+
var middleware = function middleware(input, next) {
|
87
|
+
var container = useContainer();
|
88
|
+
return run(input, {
|
89
|
+
container: container,
|
90
|
+
onLast: next
|
91
|
+
});
|
92
|
+
};
|
93
|
+
|
94
|
+
var pipeline = (_pipeline = {}, _defineProperty(_pipeline, PipelineSymbol, true), _defineProperty(_pipeline, "use", use), _defineProperty(_pipeline, "run", run), _defineProperty(_pipeline, "middleware", middleware), _pipeline);
|
95
|
+
return pipeline;
|
96
|
+
};
|
97
|
+
export var createAsyncPipeline = function createAsyncPipeline(options) {
|
98
|
+
var pipeline = createPipeline(options);
|
99
|
+
return _objectSpread({}, pipeline);
|
100
|
+
};
|
@@ -1,30 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
6
|
-
|
7
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
8
|
-
|
9
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
10
|
-
|
11
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
12
|
-
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
14
|
-
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
2
|
+
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
4
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
15
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
16
|
-
|
17
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
18
|
-
|
19
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
20
|
-
|
21
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
22
|
-
|
23
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
24
|
-
|
25
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
26
|
-
|
27
|
-
import { runWithContainer, createContainer } from 'farrow-pipeline';
|
6
|
+
import { runWithContainer, createContainer } from "../farrow-pipeline";
|
28
7
|
import { isObject, generateRunner, hasOwnProperty, DEFAULT_OPTIONS } from "./sync";
|
29
8
|
import { useRunner } from "./runner";
|
30
9
|
var ASYNC_PLUGIN_SYMBOL = 'ASYNC_PLUGIN_SYMBOL';
|
@@ -1,26 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
8
|
-
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
10
|
-
|
11
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
12
|
-
|
13
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
14
|
-
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
16
|
-
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
18
|
-
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
20
|
-
|
21
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
22
|
-
|
23
|
-
import { isPipeline, createPipeline, runWithContainer, createContainer } from 'farrow-pipeline';
|
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
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
5
|
+
import { isPipeline, createPipeline, runWithContainer, createContainer } from "../farrow-pipeline";
|
24
6
|
import { isWaterfall, createWaterfall, isAsyncWaterfall, createAsyncWaterfall } from "../waterfall";
|
25
7
|
import { isWorkflow, createWorkflow, isAsyncWorkflow, createAsyncWorkflow, isParallelWorkflow, createParallelWorkflow } from "../workflow";
|
26
8
|
import { RunnerContext, useRunner } from "./runner";
|
@@ -1,36 +1,16 @@
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
1
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
-
|
3
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
4
|
-
|
5
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
6
|
-
|
7
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
8
|
-
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
10
|
-
|
11
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
12
|
-
|
13
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
14
|
-
|
15
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
16
|
-
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
18
|
-
|
19
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
20
|
-
|
21
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
22
|
-
|
23
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
24
|
-
|
25
|
-
import { createAsyncPipeline, useContainer } from 'farrow-pipeline';
|
6
|
+
import { createAsyncPipeline, useContainer } from "../farrow-pipeline";
|
26
7
|
var ASYNC_WATERFALL_SYMBOL = Symbol('ASYNC_WATERFALL_SYMBOL');
|
27
8
|
export var getAsyncBrook = function getAsyncBrook(input) {
|
28
9
|
if (typeof input === 'function') {
|
29
10
|
return input;
|
30
11
|
} else if (input && typeof input.middleware === 'function') {
|
31
12
|
return input.middleware;
|
32
|
-
}
|
33
|
-
|
13
|
+
}
|
34
14
|
|
35
15
|
throw new Error("".concat(input, " is not a AsyncBrook or { brook: AsyncBrook }"));
|
36
16
|
};
|
@@ -55,7 +35,6 @@ export var createAsyncWaterfall = function createAsyncWaterfall() {
|
|
55
35
|
};
|
56
36
|
|
57
37
|
var middleware = function middleware(input) {
|
58
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
59
38
|
var container = useContainer();
|
60
39
|
return pipeline.run(input, {
|
61
40
|
container: container,
|
@@ -1,30 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6
|
-
|
7
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
8
|
-
|
9
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
10
|
-
|
11
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
12
|
-
|
13
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
14
|
-
|
15
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
16
|
-
|
17
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
18
|
-
|
19
|
-
import { useContainer, createPipeline } from 'farrow-pipeline';
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
4
|
+
import { useContainer, createPipeline } from "../farrow-pipeline";
|
20
5
|
var WATERFALL_SYMBOL = Symbol('WATERFALL_SYMBOL');
|
21
6
|
export var getBrook = function getBrook(input) {
|
22
7
|
if (typeof input === 'function') {
|
23
8
|
return input;
|
24
9
|
} else if (input && typeof input.middleware === 'function') {
|
25
10
|
return input.middleware;
|
26
|
-
}
|
27
|
-
|
11
|
+
}
|
28
12
|
|
29
13
|
throw new Error("".concat(input, " is not a Brook or { brook: Brook }"));
|
30
14
|
};
|
@@ -49,7 +33,6 @@ export var createWaterfall = function createWaterfall() {
|
|
49
33
|
};
|
50
34
|
|
51
35
|
var middleware = function middleware(input) {
|
52
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
53
36
|
var container = useContainer();
|
54
37
|
return pipeline.run(input, {
|
55
38
|
container: container,
|
@@ -1,30 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
5
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
3
6
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
|
-
|
5
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
6
|
-
|
7
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
8
|
-
|
9
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
10
|
-
|
11
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
12
|
-
|
13
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
14
|
-
|
15
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
16
|
-
|
17
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
18
|
-
|
19
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
20
|
-
|
21
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
22
|
-
|
23
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
24
|
-
|
25
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
26
|
-
|
27
|
-
import { createAsyncPipeline } from 'farrow-pipeline';
|
7
|
+
import { createAsyncPipeline } from "../farrow-pipeline";
|
28
8
|
var ASYNC_WORKFLOW_SYMBOL = Symbol('ASYNC_WORKFLOW_SYMBOL');
|
29
9
|
export var isAsyncWorkflow = function isAsyncWorkflow(input) {
|
30
10
|
return Boolean(input === null || input === void 0 ? void 0 : input[ASYNC_WORKFLOW_SYMBOL]);
|
@@ -1,28 +1,9 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
1
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
-
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
|
-
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
6
|
-
|
7
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
8
|
-
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
10
|
-
|
11
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
12
|
-
|
13
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
14
|
-
|
15
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
16
|
-
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
18
|
-
|
19
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
20
|
-
|
21
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
22
|
-
|
23
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
24
|
-
|
25
|
-
import { createPipeline } from 'farrow-pipeline';
|
6
|
+
import { createPipeline } from "../farrow-pipeline";
|
26
7
|
var PARALLEL_WORKFLOW_SYMBOL = Symbol('PARALLEL_WORKFLOW_SYMBOL');
|
27
8
|
export var isParallelWorkflow = function isParallelWorkflow(input) {
|
28
9
|
return Boolean(input === null || input === void 0 ? void 0 : input[PARALLEL_WORKFLOW_SYMBOL]);
|
@@ -1,28 +1,9 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
4
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
1
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
2
|
-
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
|
-
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
6
|
-
|
7
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
8
|
-
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
10
|
-
|
11
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
12
|
-
|
13
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
14
|
-
|
15
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
16
|
-
|
17
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
18
|
-
|
19
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
20
|
-
|
21
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
22
|
-
|
23
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
24
|
-
|
25
|
-
import { createPipeline } from 'farrow-pipeline';
|
6
|
+
import { createPipeline } from "../farrow-pipeline";
|
26
7
|
var WORKFLOW_SYMBOL = Symbol('WORKFLOW_SYMBOL');
|
27
8
|
export var createWorkflow = function createWorkflow() {
|
28
9
|
var pipeline = createPipeline();
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*/
|
5
|
+
export declare type AnyFn = (...args: any) => any;
|
6
|
+
export declare type Hooks = {
|
7
|
+
[key: string]: AnyFn;
|
8
|
+
};
|
9
|
+
export declare type AsyncHooks = {
|
10
|
+
enable: () => void;
|
11
|
+
disable: () => void;
|
12
|
+
set: (value: Hooks) => void;
|
13
|
+
get: () => Hooks | undefined;
|
14
|
+
clear: () => void;
|
15
|
+
entries: () => IterableIterator<[number, Hooks]>;
|
16
|
+
} | undefined;
|
17
|
+
export declare let asyncHooks: AsyncHooks;
|
18
|
+
export declare const impl: (implimentations: AsyncHooks) => void;
|
19
|
+
export declare const reset: () => void;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
declare const ContextSymbol: unique symbol;
|
2
|
+
export declare type Context<T = any> = {
|
3
|
+
id: symbol;
|
4
|
+
[ContextSymbol]: T;
|
5
|
+
create: (value: T) => Context<T>;
|
6
|
+
use: () => {
|
7
|
+
value: T;
|
8
|
+
};
|
9
|
+
get: () => T;
|
10
|
+
set: (value: T) => void;
|
11
|
+
};
|
12
|
+
export declare const createContext: <T>(value: T) => Context<T>;
|
13
|
+
export declare type ContextStorage = {
|
14
|
+
[key: string]: Context;
|
15
|
+
};
|
16
|
+
export declare type Container = {
|
17
|
+
read: <V>(Context: Context<V>) => V;
|
18
|
+
write: <V>(Context: Context<V>, value: V) => void;
|
19
|
+
};
|
20
|
+
export declare const createContainer: (ContextStorage?: ContextStorage) => Container;
|
21
|
+
export declare type Hooks = {
|
22
|
+
useContainer: () => Container;
|
23
|
+
};
|
24
|
+
export declare const runHooks: <F extends import("./asyncHooksInterface").AnyFn>(f: F, implementations: Hooks) => ReturnType<F>;
|
25
|
+
export declare const useContainer: () => Container;
|
26
|
+
export declare const fromContainer: (container: Container) => Hooks;
|
27
|
+
export declare const runWithContainer: <F extends (...args: any) => any>(f: F, container: Container) => ReturnType<F>;
|
28
|
+
export {};
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*/
|
5
|
+
export declare type Next<I = unknown, O = unknown> = (input?: I) => O;
|
6
|
+
export declare type CounterCallback<I = unknown, O = unknown> = (index: number, input: I, next: Next<I, O>) => O;
|
7
|
+
export declare type Counter<I = unknown, O = unknown> = {
|
8
|
+
start: (input: I) => O;
|
9
|
+
dispatch: (index: number, input: I) => O;
|
10
|
+
};
|
11
|
+
export declare const createCounter: <I, O>(callback: CounterCallback<I, O>) => Counter<I, O>;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*/
|
5
|
+
import { Hooks, AnyFn } from './asyncHooksInterface';
|
6
|
+
export declare const createHooks: <HS extends Hooks>(defaultHooks: HS) => {
|
7
|
+
run: <F extends AnyFn>(f: F, implementations: HS) => ReturnType<F>;
|
8
|
+
hooks: HS;
|
9
|
+
};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
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
|
+
*/
|
19
|
+
export * from './pipeline';
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/**
|
2
|
+
* modified from https://github.com/farrow-js/farrow/tree/master/packages/farrow-pipeline
|
3
|
+
* license at https://github.com/farrow-js/farrow/blob/master/LICENSE
|
4
|
+
*/
|
5
|
+
import { createContext, createContainer, ContextStorage, Context, Container, useContainer, runWithContainer } from './context';
|
6
|
+
import { Next } from './counter';
|
7
|
+
export type { Next };
|
8
|
+
export { createContext, createContainer, useContainer, runWithContainer };
|
9
|
+
export type { ContextStorage, Context, Container };
|
10
|
+
export declare type Middleware<I = unknown, O = unknown> = (input: I, next: Next<I, O>) => O;
|
11
|
+
export declare type Middlewares<I = unknown, O = unknown> = Middleware<I, O>[];
|
12
|
+
export declare const isPipeline: (input: any) => input is Pipeline<unknown, unknown>;
|
13
|
+
declare const PipelineSymbol: unique symbol;
|
14
|
+
export declare type PipelineOptions = {
|
15
|
+
contexts?: ContextStorage;
|
16
|
+
};
|
17
|
+
export declare type RunPipelineOptions<I = unknown, O = unknown> = {
|
18
|
+
container?: Container;
|
19
|
+
onLast?: (input: I) => O;
|
20
|
+
onLastWithContext?: boolean;
|
21
|
+
};
|
22
|
+
export declare type MiddlewareInput<I = unknown, O = unknown> = Middleware<I, O> | {
|
23
|
+
middleware: Middleware<I, O>;
|
24
|
+
};
|
25
|
+
export declare type MiddlewareType<T extends MiddlewareInput> = T extends MiddlewareInput<infer I, infer O> ? Middleware<I, O> : never;
|
26
|
+
export declare type Pipeline<I = unknown, O = unknown> = {
|
27
|
+
[PipelineSymbol]: true;
|
28
|
+
use: (...inputs: MiddlewareInput<I, O>[]) => Pipeline<I, O>;
|
29
|
+
run: (input: I, options?: RunPipelineOptions<I, O>) => O;
|
30
|
+
middleware: Middleware<I, O>;
|
31
|
+
};
|
32
|
+
export declare const createPipeline: <I, O>(options?: PipelineOptions | undefined) => Pipeline<I, O>;
|
33
|
+
export declare type PipelineInput<T extends Pipeline> = T extends Pipeline<infer I> ? I : never;
|
34
|
+
export declare type PipelineOutput<T extends Pipeline> = T extends Pipeline<any, infer O> ? O : never;
|
35
|
+
export declare type MaybeAsync<T> = T | Promise<T>;
|
36
|
+
export declare type ThunkMiddlewareInput<I, O> = () => MaybeAsync<MiddlewareInput<I, MaybeAsync<O>>>;
|
37
|
+
export declare type AsyncPipeline<I = unknown, O = unknown> = Pipeline<I, MaybeAsync<O>>;
|
38
|
+
export declare const createAsyncPipeline: <I, O>(options?: PipelineOptions | undefined) => AsyncPipeline<I, O>;
|
package/dist/types/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare const RunnerContext: import("farrow-pipeline").Context<any>;
|
1
|
+
export declare const RunnerContext: import("../farrow-pipeline").Context<any>;
|
2
2
|
export declare const useRunner: () => any;
|