postcss-normalize-repeat-style 5.0.4 → 5.1.0

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,11 +1,13 @@
1
1
  {
2
2
  "name": "postcss-normalize-repeat-style",
3
- "version": "5.0.4",
3
+ "version": "5.1.0",
4
4
  "description": "Convert two value syntax for repeat-style into one value.",
5
5
  "main": "src/index.js",
6
+ "types": "types/index.d.ts",
6
7
  "files": [
7
8
  "LICENSE-MIT",
8
- "src"
9
+ "src",
10
+ "types"
9
11
  ],
10
12
  "license": "MIT",
11
13
  "dependencies": {
package/src/index.js CHANGED
@@ -2,16 +2,29 @@
2
2
  const valueParser = require('postcss-value-parser');
3
3
  const mappings = require('./lib/map');
4
4
 
5
- function evenValues(list, index) {
5
+ /**
6
+ * @param {unknown} item
7
+ * @param {number} index
8
+ * @return {boolean}
9
+ */
10
+ function evenValues(item, index) {
6
11
  return index % 2 === 0;
7
12
  }
8
13
 
9
14
  const repeatKeywords = new Set(mappings.values());
10
15
 
16
+ /**
17
+ * @param {valueParser.Node} node
18
+ * @return {boolean}
19
+ */
11
20
  function isCommaNode(node) {
12
21
  return node.type === 'div' && node.value === ',';
13
22
  }
14
23
 
24
+ /**
25
+ * @param {valueParser.Node} node
26
+ * @return {boolean}
27
+ */
15
28
  function isVariableFunctionNode(node) {
16
29
  if (node.type !== 'function') {
17
30
  return false;
@@ -20,13 +33,17 @@ function isVariableFunctionNode(node) {
20
33
  return ['var', 'env'].includes(node.value.toLowerCase());
21
34
  }
22
35
 
36
+ /**
37
+ * @param {string} value
38
+ * @return {string}
39
+ */
23
40
  function transform(value) {
24
41
  const parsed = valueParser(value);
25
42
 
26
43
  if (parsed.nodes.length === 1) {
27
44
  return value;
28
45
  }
29
-
46
+ /** @type {{start: number?, end: number?}[]} */
30
47
  const ranges = [];
31
48
  let rangeIndex = 0;
32
49
  let shouldContinue = true;
@@ -96,7 +113,10 @@ function transform(value) {
96
113
  return;
97
114
  }
98
115
 
99
- const nodes = parsed.nodes.slice(range.start, range.end + 1);
116
+ const nodes = parsed.nodes.slice(
117
+ range.start,
118
+ /** @type {number} */ (range.end) + 1
119
+ );
100
120
 
101
121
  if (nodes.length !== 3) {
102
122
  return;
@@ -117,6 +137,10 @@ function transform(value) {
117
137
  return parsed.toString();
118
138
  }
119
139
 
140
+ /**
141
+ * @type {import('postcss').PluginCreator<void>}
142
+ * @return {import('postcss').Plugin}
143
+ */
120
144
  function pluginCreator() {
121
145
  return {
122
146
  postcssPlugin: 'postcss-normalize-repeat-style',
@@ -0,0 +1,9 @@
1
+ export = pluginCreator;
2
+ /**
3
+ * @type {import('postcss').PluginCreator<void>}
4
+ * @return {import('postcss').Plugin}
5
+ */
6
+ declare function pluginCreator(): import('postcss').Plugin;
7
+ declare namespace pluginCreator {
8
+ const postcss: true;
9
+ }
@@ -0,0 +1,15 @@
1
+ declare const _exports: {
2
+ clear(): void;
3
+ delete(key: string): boolean;
4
+ forEach(callbackfn: (value: string, key: string, map: Map<string, string>) => void, thisArg?: any): void;
5
+ get(key: string): string | undefined;
6
+ has(key: string): boolean;
7
+ set(key: string, value: string): Map<string, string>;
8
+ readonly size: number;
9
+ entries(): IterableIterator<[string, string]>;
10
+ keys(): IterableIterator<string>;
11
+ values(): IterableIterator<string>;
12
+ [Symbol.iterator](): IterableIterator<[string, string]>;
13
+ readonly [Symbol.toStringTag]: string;
14
+ };
15
+ export = _exports;