@iconify/tools 4.0.0-beta.7 → 4.0.0-beta.9

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.
@@ -60,7 +60,7 @@ function detectIconSetPalette(iconSet) {
60
60
  },
61
61
  ["icon"]
62
62
  );
63
- return palette === void 0 ? null : palette;
63
+ return palette ?? null;
64
64
  }
65
65
 
66
66
  exports.detectIconSetPalette = detectIconSetPalette;
@@ -58,7 +58,7 @@ function detectIconSetPalette(iconSet) {
58
58
  },
59
59
  ["icon"]
60
60
  );
61
- return palette === void 0 ? null : palette;
61
+ return palette ?? null;
62
62
  }
63
63
 
64
64
  export { detectIconSetPalette };
@@ -128,7 +128,7 @@ function parseColors(svg, options = {}) {
128
128
  svg_parseStyle.parseSVGStyle(svg, (item) => {
129
129
  const prop = item.prop;
130
130
  const value = item.value;
131
- if (propsToCheck.indexOf(prop) === -1) {
131
+ if (!propsToCheck.includes(prop)) {
132
132
  return value;
133
133
  }
134
134
  const attr = prop;
@@ -213,7 +213,7 @@ function parseColors(svg, options = {}) {
213
213
  }
214
214
  if (svg_data_tags.animateTags.has(tagName)) {
215
215
  const attr = attribs.attributeName;
216
- if (propsToCheck.indexOf(attr) !== -1) {
216
+ if (propsToCheck.includes(attr)) {
217
217
  for (let i = 0; i < animatePropsToCheck.length; i++) {
218
218
  const elementProp = animatePropsToCheck[i];
219
219
  const fullValue = attribs[elementProp];
@@ -126,7 +126,7 @@ function parseColors(svg, options = {}) {
126
126
  parseSVGStyle(svg, (item) => {
127
127
  const prop = item.prop;
128
128
  const value = item.value;
129
- if (propsToCheck.indexOf(prop) === -1) {
129
+ if (!propsToCheck.includes(prop)) {
130
130
  return value;
131
131
  }
132
132
  const attr = prop;
@@ -211,7 +211,7 @@ function parseColors(svg, options = {}) {
211
211
  }
212
212
  if (animateTags.has(tagName)) {
213
213
  const attr = attribs.attributeName;
214
- if (propsToCheck.indexOf(attr) !== -1) {
214
+ if (propsToCheck.includes(attr)) {
215
215
  for (let i = 0; i < animatePropsToCheck.length; i++) {
216
216
  const elementProp = animatePropsToCheck[i];
217
217
  const fullValue = attribs[elementProp];
@@ -31,7 +31,7 @@ require('tar');
31
31
 
32
32
  async function downloadGitRepo(options) {
33
33
  const { remote, branch } = options;
34
- const hasHashInTarget = options.target.indexOf("{hash}") !== -1;
34
+ const hasHashInTarget = options.target.includes("{hash}");
35
35
  const ifModifiedSince = options.ifModifiedSince;
36
36
  if (ifModifiedSince || hasHashInTarget) {
37
37
  const result = await misc_exec.execAsync(
@@ -29,7 +29,7 @@ import 'tar';
29
29
 
30
30
  async function downloadGitRepo(options) {
31
31
  const { remote, branch } = options;
32
- const hasHashInTarget = options.target.indexOf("{hash}") !== -1;
32
+ const hasHashInTarget = options.target.includes("{hash}");
33
33
  const ifModifiedSince = options.ifModifiedSince;
34
34
  if (ifModifiedSince || hasHashInTarget) {
35
35
  const result = await execAsync(
@@ -145,10 +145,9 @@ class IconSet {
145
145
  * List icons
146
146
  */
147
147
  list(types = ["icon", "variation"]) {
148
- return Object.keys(this.entries).filter((name) => {
149
- const type = this.entries[name].type;
150
- return types.indexOf(type) !== -1;
151
- });
148
+ return Object.keys(this.entries).filter(
149
+ (name) => types.includes(this.entries[name].type)
150
+ );
152
151
  }
153
152
  /**
154
153
  * forEach function to loop through all entries.
@@ -143,10 +143,9 @@ class IconSet {
143
143
  * List icons
144
144
  */
145
145
  list(types = ["icon", "variation"]) {
146
- return Object.keys(this.entries).filter((name) => {
147
- const type = this.entries[name].type;
148
- return types.indexOf(type) !== -1;
149
- });
146
+ return Object.keys(this.entries).filter(
147
+ (name) => types.includes(this.entries[name].type)
148
+ );
150
149
  }
151
150
  /**
152
151
  * forEach function to loop through all entries.
@@ -64,7 +64,7 @@ function getFigmaIconNodes(document, options) {
64
64
  const newParents = parents.concat([parentItem]);
65
65
  if (!parents.length && options.pages) {
66
66
  const allowedPages = options.pages;
67
- if (allowedPages.indexOf(node.id) === -1 && allowedPages.indexOf(node.name.trim()) === -1) {
67
+ if (!allowedPages.includes(node.id) && !allowedPages.includes(node.name.trim())) {
68
68
  return;
69
69
  }
70
70
  } else {
@@ -62,7 +62,7 @@ function getFigmaIconNodes(document, options) {
62
62
  const newParents = parents.concat([parentItem]);
63
63
  if (!parents.length && options.pages) {
64
64
  const allowedPages = options.pages;
65
- if (allowedPages.indexOf(node.id) === -1 && allowedPages.indexOf(node.name.trim()) === -1) {
65
+ if (!allowedPages.includes(node.id) && !allowedPages.includes(node.name.trim())) {
66
66
  return;
67
67
  }
68
68
  } else {
@@ -35,7 +35,7 @@ async function compareDirectories(dir1, dir2, options) {
35
35
  );
36
36
  for (let i = 0; i < files1.length; i++) {
37
37
  const file = files1[i];
38
- if (files2.indexOf(file) === -1) {
38
+ if (!files2.includes(file)) {
39
39
  return false;
40
40
  }
41
41
  const ext = file.split(".").pop().toLowerCase();
@@ -54,8 +54,8 @@ async function compareDirectories(dir1, dir2, options) {
54
54
  continue;
55
55
  }
56
56
  if (ignoreNewLine) {
57
- content1 = content1.replace(/\s+\n/g, "\n").trimRight();
58
- content2 = content2.replace(/\s+\n/g, "\n").trimRight();
57
+ content1 = content1.replace(/\s+\n/g, "\n").trimEnd();
58
+ content2 = content2.replace(/\s+\n/g, "\n").trimEnd();
59
59
  }
60
60
  if (ignoreVersions && file.split("/").pop() === "package.json") {
61
61
  const data1 = JSON.parse(content1);
@@ -33,7 +33,7 @@ async function compareDirectories(dir1, dir2, options) {
33
33
  );
34
34
  for (let i = 0; i < files1.length; i++) {
35
35
  const file = files1[i];
36
- if (files2.indexOf(file) === -1) {
36
+ if (!files2.includes(file)) {
37
37
  return false;
38
38
  }
39
39
  const ext = file.split(".").pop().toLowerCase();
@@ -52,8 +52,8 @@ async function compareDirectories(dir1, dir2, options) {
52
52
  continue;
53
53
  }
54
54
  if (ignoreNewLine) {
55
- content1 = content1.replace(/\s+\n/g, "\n").trimRight();
56
- content2 = content2.replace(/\s+\n/g, "\n").trimRight();
55
+ content1 = content1.replace(/\s+\n/g, "\n").trimEnd();
56
+ content2 = content2.replace(/\s+\n/g, "\n").trimEnd();
57
57
  }
58
58
  if (ignoreVersions && file.split("/").pop() === "package.json") {
59
59
  const data1 = JSON.parse(content1);
@@ -223,7 +223,7 @@ function cleanPath(path) {
223
223
  if (index < 1) {
224
224
  break;
225
225
  }
226
- if (item.params[index - 1].indexOf(".") !== -1) {
226
+ if (item.params[index - 1].includes(".")) {
227
227
  break;
228
228
  }
229
229
  default:
@@ -221,7 +221,7 @@ function cleanPath(path) {
221
221
  if (index < 1) {
222
222
  break;
223
223
  }
224
- if (item.params[index - 1].indexOf(".") !== -1) {
224
+ if (item.params[index - 1].includes(".")) {
225
225
  break;
226
226
  }
227
227
  default:
@@ -93,7 +93,7 @@ function cleanupGlobalStyle(svg) {
93
93
  break;
94
94
  case "class": {
95
95
  const className = $element.attr("class");
96
- if (className && getClassList(className).indexOf(value) !== -1) {
96
+ if (className && getClassList(className).includes(value)) {
97
97
  return true;
98
98
  }
99
99
  }
@@ -91,7 +91,7 @@ function cleanupGlobalStyle(svg) {
91
91
  break;
92
92
  case "class": {
93
93
  const className = $element.attr("class");
94
- if (className && getClassList(className).indexOf(value) !== -1) {
94
+ if (className && getClassList(className).includes(value)) {
95
95
  return true;
96
96
  }
97
97
  }
@@ -60,7 +60,7 @@ function runSVGO(svg, options = {}) {
60
60
  if (options.plugins) {
61
61
  plugins = options.plugins;
62
62
  } else {
63
- const animated = code.indexOf("<animate") !== -1 || code.indexOf("<set") !== -1;
63
+ const animated = code.includes("<animate") || code.includes("<set");
64
64
  plugins = getSVGOPlugins({
65
65
  ...options,
66
66
  animated
@@ -58,7 +58,7 @@ function runSVGO(svg, options = {}) {
58
58
  if (options.plugins) {
59
59
  plugins = options.plugins;
60
60
  } else {
61
- const animated = code.indexOf("<animate") !== -1 || code.indexOf("<set") !== -1;
61
+ const animated = code.includes("<animate") || code.includes("<set");
62
62
  plugins = getSVGOPlugins({
63
63
  ...options,
64
64
  animated
@@ -263,7 +263,7 @@ function analyseSVGStructure(svg, options = {}) {
263
263
  usedItems = usedItems.slice(0);
264
264
  usedItems.push(element._index);
265
265
  element._childElements?.forEach((childIndex) => {
266
- if (usedItems.indexOf(childIndex) !== -1) {
266
+ if (usedItems.includes(childIndex)) {
267
267
  throw new Error("Recursion");
268
268
  }
269
269
  const childItem = {
@@ -261,7 +261,7 @@ function analyseSVGStructure(svg, options = {}) {
261
261
  usedItems = usedItems.slice(0);
262
262
  usedItems.push(element._index);
263
263
  element._childElements?.forEach((childIndex) => {
264
- if (usedItems.indexOf(childIndex) !== -1) {
264
+ if (usedItems.includes(childIndex)) {
265
265
  throw new Error("Recursion");
266
266
  }
267
267
  const childItem = {
@@ -26,7 +26,7 @@ function convertStyleToAttrs(svg) {
26
26
  // Attributes / properties now allowed
27
27
  svg_data_attributes.badAttributes.has(prop) || svg_data_attributes.badSoftwareAttributes.has(prop) || svg_data_attributes.badAttributePrefixes.has(prop.split("-").shift())
28
28
  ) {
29
- return void 0;
29
+ return;
30
30
  }
31
31
  hasStyle = true;
32
32
  return item.value;
@@ -24,7 +24,7 @@ function convertStyleToAttrs(svg) {
24
24
  // Attributes / properties now allowed
25
25
  badAttributes.has(prop) || badSoftwareAttributes.has(prop) || badAttributePrefixes.has(prop.split("-").shift())
26
26
  ) {
27
- return void 0;
27
+ return;
28
28
  }
29
29
  hasStyle = true;
30
30
  return item.value;
package/lib/svg/index.cjs CHANGED
@@ -31,7 +31,7 @@ class SVG {
31
31
  if (customisations) {
32
32
  const data = utils.iconToSVG(this.getIcon(), customisations);
33
33
  let svgAttributes = ' xmlns="http://www.w3.org/2000/svg"';
34
- if (data.body.indexOf("xlink:") !== -1) {
34
+ if (data.body.includes("xlink:")) {
35
35
  svgAttributes += ' xmlns:xlink="http://www.w3.org/1999/xlink"';
36
36
  }
37
37
  for (const key in data.attributes) {
package/lib/svg/index.mjs CHANGED
@@ -15,7 +15,7 @@ class SVG {
15
15
  if (customisations) {
16
16
  const data = iconToSVG(this.getIcon(), customisations);
17
17
  let svgAttributes = ' xmlns="http://www.w3.org/2000/svg"';
18
- if (data.body.indexOf("xlink:") !== -1) {
18
+ if (data.body.includes("xlink:")) {
19
19
  svgAttributes += ' xmlns:xlink="http://www.w3.org/1999/xlink"';
20
20
  }
21
21
  for (const key in data.attributes) {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "description": "Collection of functions for cleaning up and parsing SVG for Iconify project",
5
5
  "author": "Vjacheslav Trushkin",
6
- "version": "4.0.0-beta.7",
6
+ "version": "4.0.0-beta.9",
7
7
  "publishConfig": {
8
8
  "tag": "next"
9
9
  },
@@ -26,7 +26,7 @@
26
26
  "extract-zip": "^2.0.1",
27
27
  "local-pkg": "^0.4.3",
28
28
  "pathe": "^1.1.1",
29
- "svgo": "3.0.3",
29
+ "svgo": "^3.1.0",
30
30
  "tar": "^6.2.0"
31
31
  },
32
32
  "devDependencies": {