Blame view

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