postcss-normalize-timing-functions 4.0.1 → 4.0.2

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/dist/index.js CHANGED
@@ -32,31 +32,39 @@ function reduce(node) {
32
32
  return false;
33
33
  }
34
34
 
35
- const value = node.value.toLowerCase();
35
+ const lowerCasedValue = node.value.toLowerCase();
36
36
 
37
- if (value === 'steps') {
37
+ if (lowerCasedValue === 'steps') {
38
38
  // Don't bother checking the step-end case as it has the same length
39
39
  // as steps(1)
40
40
  if (getValue(node.nodes[0]) === 1 && node.nodes[2] && node.nodes[2].value.toLowerCase() === 'start') {
41
41
  node.type = 'word';
42
42
  node.value = 'step-start';
43
+
43
44
  delete node.nodes;
45
+
44
46
  return;
45
47
  }
48
+
46
49
  // The end case is actually the browser default, so it isn't required.
47
50
  if (node.nodes[2] && node.nodes[2].value.toLowerCase() === 'end') {
48
51
  node.nodes = [node.nodes[0]];
52
+
49
53
  return;
50
54
  }
55
+
51
56
  return false;
52
57
  }
53
- if (value === 'cubic-bezier') {
58
+
59
+ if (lowerCasedValue === 'cubic-bezier') {
54
60
  const match = getMatch(node.nodes.filter(evenValues).map(getValue));
55
61
 
56
62
  if (match) {
57
63
  node.type = 'word';
58
64
  node.value = match;
65
+
59
66
  delete node.nodes;
67
+
60
68
  return;
61
69
  }
62
70
  }
@@ -64,8 +72,21 @@ function reduce(node) {
64
72
 
65
73
  exports.default = (0, _postcss.plugin)('postcss-normalize-timing-functions', () => {
66
74
  return css => {
75
+ const cache = {};
76
+
67
77
  css.walkDecls(/(animation|transition)(-timing-function|$)/i, decl => {
68
- decl.value = (0, _postcssValueParser2.default)(decl.value).walk(reduce).toString();
78
+ const value = decl.value;
79
+
80
+ if (cache[value]) {
81
+ decl.value = cache[value];
82
+
83
+ return;
84
+ }
85
+
86
+ const result = (0, _postcssValueParser2.default)(value).walk(reduce).toString();
87
+
88
+ decl.value = result;
89
+ cache[value] = result;
69
90
  });
70
91
  };
71
92
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postcss-normalize-timing-functions",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Normalize CSS animation/transition timing functions.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/CHANGELOG.md DELETED
@@ -1,4 +0,0 @@
1
- # 4.0.0-rc.0
2
-
3
- * Initial commit. This module was previously part of other cssnano modules and
4
- has been extracted out.