agora-toolchain 3.7.7 → 3.7.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agora-toolchain",
3
- "version": "3.7.7",
3
+ "version": "3.7.8",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "agora-tc-transpile": "./scripts/transpile.js",
@@ -0,0 +1,14 @@
1
+ // excluding regex trick: http://www.rexegg.com/regex-best-trick.html
2
+
3
+ // Not anything inside double quotes
4
+ // Not anything inside single quotes
5
+ // Not anything inside url()
6
+ // Any digit followed by px
7
+ // !singlequotes|!doublequotes|!url()|pixelunit
8
+ function getUnitRegexp(unit) {
9
+ return new RegExp('"[^"]+"|\'[^\']+\'|url\\([^\\)]+\\)|(\\d*\\.?\\d+)' + unit, 'g');
10
+ }
11
+
12
+ module.exports = {
13
+ getUnitRegexp,
14
+ };
@@ -0,0 +1,118 @@
1
+ var filterPropList = {
2
+ exact: function (list) {
3
+ return list.filter(function (m) {
4
+ return m.match(/^[^\*\!]+$/);
5
+ });
6
+ },
7
+ contain: function (list) {
8
+ return list
9
+ .filter(function (m) {
10
+ return m.match(/^\*.+\*$/);
11
+ })
12
+ .map(function (m) {
13
+ return m.substr(1, m.length - 2);
14
+ });
15
+ },
16
+ endWith: function (list) {
17
+ return list
18
+ .filter(function (m) {
19
+ return m.match(/^\*[^\*]+$/);
20
+ })
21
+ .map(function (m) {
22
+ return m.substr(1);
23
+ });
24
+ },
25
+ startWith: function (list) {
26
+ return list
27
+ .filter(function (m) {
28
+ return m.match(/^[^\*\!]+\*$/);
29
+ })
30
+ .map(function (m) {
31
+ return m.substr(0, m.length - 1);
32
+ });
33
+ },
34
+ notExact: function (list) {
35
+ return list
36
+ .filter(function (m) {
37
+ return m.match(/^\![^\*].*$/);
38
+ })
39
+ .map(function (m) {
40
+ return m.substr(1);
41
+ });
42
+ },
43
+ notContain: function (list) {
44
+ return list
45
+ .filter(function (m) {
46
+ return m.match(/^\!\*.+\*$/);
47
+ })
48
+ .map(function (m) {
49
+ return m.substr(2, m.length - 3);
50
+ });
51
+ },
52
+ notEndWith: function (list) {
53
+ return list
54
+ .filter(function (m) {
55
+ return m.match(/^\!\*[^\*]+$/);
56
+ })
57
+ .map(function (m) {
58
+ return m.substr(2);
59
+ });
60
+ },
61
+ notStartWith: function (list) {
62
+ return list
63
+ .filter(function (m) {
64
+ return m.match(/^\![^\*]+\*$/);
65
+ })
66
+ .map(function (m) {
67
+ return m.substr(1, m.length - 2);
68
+ });
69
+ },
70
+ };
71
+
72
+ function createPropListMatcher(propList) {
73
+ var hasWild = propList.indexOf('*') > -1;
74
+ var matchAll = hasWild && propList.length === 1;
75
+ var lists = {
76
+ exact: filterPropList.exact(propList),
77
+ contain: filterPropList.contain(propList),
78
+ startWith: filterPropList.startWith(propList),
79
+ endWith: filterPropList.endWith(propList),
80
+ notExact: filterPropList.notExact(propList),
81
+ notContain: filterPropList.notContain(propList),
82
+ notStartWith: filterPropList.notStartWith(propList),
83
+ notEndWith: filterPropList.notEndWith(propList),
84
+ };
85
+ return function (prop) {
86
+ if (matchAll) return true;
87
+ return (
88
+ (hasWild ||
89
+ lists.exact.indexOf(prop) > -1 ||
90
+ lists.contain.some(function (m) {
91
+ return prop.indexOf(m) > -1;
92
+ }) ||
93
+ lists.startWith.some(function (m) {
94
+ return prop.indexOf(m) === 0;
95
+ }) ||
96
+ lists.endWith.some(function (m) {
97
+ return prop.indexOf(m) === prop.length - m.length;
98
+ })) &&
99
+ !(
100
+ lists.notExact.indexOf(prop) > -1 ||
101
+ lists.notContain.some(function (m) {
102
+ return prop.indexOf(m) > -1;
103
+ }) ||
104
+ lists.notStartWith.some(function (m) {
105
+ return prop.indexOf(m) === 0;
106
+ }) ||
107
+ lists.notEndWith.some(function (m) {
108
+ return prop.indexOf(m) === prop.length - m.length;
109
+ })
110
+ )
111
+ );
112
+ };
113
+ }
114
+
115
+ module.exports = {
116
+ filterPropList,
117
+ createPropListMatcher,
118
+ };