1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.isInitialOrHasNoParents = isInitialOrHasNoParents;
|
7 | exports.isInvalidOrder = isInvalidOrder;
|
8 | exports.getOrder = getOrder;
|
9 | exports.getLoaderObject = getLoaderObject;
|
10 | exports.mergeOptions = mergeOptions;
|
11 | exports.isString = isString;
|
12 | exports.isFunction = isFunction;
|
13 | exports.isType = isType;
|
14 | function isInitialOrHasNoParents(chunk) {
|
15 | return chunk.isInitial() || chunk.parents.length === 0;
|
16 | }
|
17 |
|
18 | function isInvalidOrder(a, b) {
|
19 | var bBeforeA = a.getPrevModules().indexOf(b) >= 0;
|
20 | var aBeforeB = b.getPrevModules().indexOf(a) >= 0;
|
21 | return aBeforeB && bBeforeA;
|
22 | }
|
23 |
|
24 | function getOrder(a, b) {
|
25 | var aOrder = a.getOrder();
|
26 | var bOrder = b.getOrder();
|
27 | if (aOrder < bOrder) return -1;
|
28 | if (aOrder > bOrder) return 1;
|
29 | var aIndex = a.getOriginalModule().index2;
|
30 | var bIndex = b.getOriginalModule().index2;
|
31 | if (aIndex < bIndex) return -1;
|
32 | if (aIndex > bIndex) return 1;
|
33 | var bBeforeA = a.getPrevModules().indexOf(b) >= 0;
|
34 | var aBeforeB = b.getPrevModules().indexOf(a) >= 0;
|
35 | if (aBeforeB && !bBeforeA) return -1;
|
36 | if (!aBeforeB && bBeforeA) return 1;
|
37 | var ai = a.identifier();
|
38 | var bi = b.identifier();
|
39 | if (ai < bi) return -1;
|
40 | if (ai > bi) return 1;
|
41 | return 0;
|
42 | }
|
43 |
|
44 | function getLoaderObject(loader) {
|
45 | if (isString(loader)) {
|
46 | return { loader };
|
47 | }
|
48 | return loader;
|
49 | }
|
50 |
|
51 | function mergeOptions(a, b) {
|
52 | if (!b) return a;
|
53 | Object.keys(b).forEach(function (key) {
|
54 | a[key] = b[key];
|
55 | });
|
56 | return a;
|
57 | }
|
58 |
|
59 | function isString(a) {
|
60 | return typeof a === 'string';
|
61 | }
|
62 |
|
63 | function isFunction(a) {
|
64 | return typeof a === 'function';
|
65 | }
|
66 |
|
67 | function isType(type, obj) {
|
68 | return Object.prototype.toString.call(obj) === `[object ${type}]`;
|
69 | } |
\ | No newline at end of file |