@cyberalien/svg-utils 1.0.2 → 1.0.3

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.
@@ -0,0 +1,6 @@
1
+ type ComparisonKey = string | number | symbol | object;
2
+ /**
3
+ * Compare keys, return true on match
4
+ */
5
+ declare function compareKeys(key1: ComparisonKey, key2: ComparisonKey): boolean;
6
+ export { ComparisonKey, compareKeys };
@@ -0,0 +1,12 @@
1
+ import { sortObject } from "./sort-object.js";
2
+
3
+ /**
4
+ * Compare keys, return true on match
5
+ */
6
+ function compareKeys(key1, key2) {
7
+ if (key1 === key2) return true;
8
+ if (typeof key1 !== "object" || typeof key2 !== "object" || !key1 || !key2) return false;
9
+ return JSON.stringify(sortObject(key1)) === JSON.stringify(sortObject(key2));
10
+ }
11
+
12
+ export { compareKeys };
@@ -1,4 +1,4 @@
1
- type ComparisonKey = string | number | symbol | object;
1
+ import { ComparisonKey } from "./keys.js";
2
2
  /**
3
3
  * Make sure multiple instances of Promise or callback are not ran at the same time
4
4
  */
@@ -1,15 +1,7 @@
1
- import { sortObject } from "./sort-object.js";
1
+ import { compareKeys } from "./keys.js";
2
2
 
3
3
  let cache = [];
4
4
  /**
5
- * Compare keys, return true on match
6
- */
7
- function compareKeys(key1, key2) {
8
- if (key1 === key2) return true;
9
- if (typeof key1 !== "object" || typeof key2 !== "object" || !key1 || !key2) return false;
10
- return JSON.stringify(sortObject(key1)) === JSON.stringify(sortObject(key2));
11
- }
12
- /**
13
5
  * Make sure multiple instances of Promise or callback are not ran at the same time
14
6
  */
15
7
  function uniquePromise(key, callback) {
package/lib/index.d.ts CHANGED
@@ -10,6 +10,7 @@ import { hashToString } from "./helpers/hash/stringify.js";
10
10
  import { getUniqueHash } from "./helpers/hash/unique.js";
11
11
  import { cloneObject } from "./helpers/misc/clone.js";
12
12
  import { compareSets, compareValues } from "./helpers/misc/compare.js";
13
+ import { ComparisonKey, compareKeys } from "./helpers/misc/keys.js";
13
14
  import { uniquePromise } from "./helpers/misc/promises.js";
14
15
  import { sortObject } from "./helpers/misc/sort-object.js";
15
16
  import { iterateXMLContent } from "./xml/iterate.js";
@@ -23,4 +24,4 @@ import { changeSVGIDs } from "./svg/ids/change.js";
23
24
  import { createUniqueIDs } from "./svg/ids/unique.js";
24
25
  import { convertSVGRootToCSS } from "./svg-css/root.js";
25
26
  import { convertSVGContentToCSSRules } from "./svg-css/content.js";
26
- export { ChangeIDResult, ClassProp, ConvertSVGContentOptions, ConvertedSVGContent, ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, StringifyXMLOptions, UniqueHashOptions, changeIDInString, changeSVGIDs, classProps, cloneObject, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGRootToCSS, createCSSClassName, createUniqueIDs, defaultClassProp, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyXMLContent, toggleClassName, uniquePromise };
27
+ export { ChangeIDResult, ClassProp, ComparisonKey, ConvertSVGContentOptions, ConvertedSVGContent, ParsedXMLNode, ParsedXMLTagElement, ParsedXMLTextElement, StringifyXMLOptions, UniqueHashOptions, changeIDInString, changeSVGIDs, classProps, cloneObject, compareKeys, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGRootToCSS, createCSSClassName, createUniqueIDs, defaultClassProp, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyXMLContent, toggleClassName, uniquePromise };
package/lib/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { cloneObject } from "./helpers/misc/clone.js";
2
2
  import { sortObject } from "./helpers/misc/sort-object.js";
3
3
  import { compareSets, compareValues } from "./helpers/misc/compare.js";
4
+ import { compareKeys } from "./helpers/misc/keys.js";
4
5
  import { uniquePromise } from "./helpers/misc/promises.js";
5
6
  import { hashToString } from "./helpers/hash/stringify.js";
6
7
  import { hashString } from "./helpers/hash/hash.js";
@@ -20,4 +21,4 @@ import { createUniqueIDs } from "./svg/ids/unique.js";
20
21
  import { convertSVGRootToCSS } from "./svg-css/root.js";
21
22
  import { convertSVGContentToCSSRules } from "./svg-css/content.js";
22
23
 
23
- export { changeIDInString, changeSVGIDs, classProps, cloneObject, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGRootToCSS, createCSSClassName, createUniqueIDs, defaultClassProp, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyXMLContent, toggleClassName, uniquePromise };
24
+ export { changeIDInString, changeSVGIDs, classProps, cloneObject, compareKeys, compareSets, compareValues, convertSVGContentToCSSRules, convertSVGRootToCSS, createCSSClassName, createUniqueIDs, defaultClassProp, getUniqueHash, hashString, hashToString, iterateXMLContent, parseXMLContent, removeDuplicateIDs, removeUnusedIDs, sortObject, splitClassName, stringifyCSSKeyframes, stringifyCSSRules, stringifyCSSSelector, stringifyXMLContent, toggleClassName, uniquePromise };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "type": "module",
4
4
  "description": "Common functions for working with SVG used by various packages.",
5
5
  "author": "Vjacheslav Trushkin",
6
- "version": "1.0.2",
6
+ "version": "1.0.3",
7
7
  "license": "MIT",
8
8
  "bugs": "https://github.com/cyberalien/svg-utils/issues",
9
9
  "homepage": "https://cyberalien.dev/",