UNPKG

1.7 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.dep = exports.DepBuilder = void 0;
4const utils_1 = require("./utils");
5class DepBuilder {
6 constructor(name) {
7 this._isDepBuilder = true;
8 if (utils_1.Is.str(name)) {
9 name = { name };
10 }
11 else if (name instanceof DepBuilder) {
12 name = name.toTaskDep();
13 }
14 this._dep = name;
15 }
16 /**
17 *
18 * Dependences are executed serially by default.
19 * If order doesn't matter and you want better performance via parallel, you can mark it as asynchronized.
20 * Asynchronized will run immediately whether there are synchronized tasks before them or not.
21 * You can pass a number as the priority of asynchronized tasks, bigger is formmer.
22 * @param priority
23 */
24 async(priority = true) {
25 this._dep.async = priority;
26 return this;
27 }
28 force() {
29 this._dep.force = true;
30 return this;
31 }
32 options(opts) {
33 if (utils_1.Is.fn(opts)) {
34 this._dep.resolveOptions = opts;
35 }
36 else {
37 this._dep.options = opts;
38 }
39 return this;
40 }
41 toTaskDep() {
42 return this._dep;
43 }
44}
45exports.DepBuilder = DepBuilder;
46function dep(dep) {
47 if (utils_1.Is.str(dep)) {
48 dep = { name: dep };
49 }
50 return new DepBuilder(dep);
51}
52exports.dep = dep;
53String.prototype.async = function (priority) {
54 return dep(this).async(priority);
55};
56String.prototype.force = function () {
57 return dep(this).force();
58};
59String.prototype.options = function (opts) {
60 return dep(this).options(opts);
61};
62//# sourceMappingURL=dep-builder.js.map
\No newline at end of file