@nemigo/helpers 2.8.0 → 2.8.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.
@@ -29,3 +29,5 @@ export declare const autoAreaHeight: (area?: HTMLTextAreaElement) => void;
29
29
  * @param [multi=false] - Есть массивы значений для одинаковых ключей
30
30
  */
31
31
  export declare const formon: <D = any>(form: FormData, multi?: boolean) => D;
32
+ export declare const toVW: (px: number) => number;
33
+ export declare const toVH: (px: number) => number;
@@ -57,3 +57,5 @@ export const formon = (form, multi = false) => {
57
57
  }
58
58
  return Object.fromEntries(form.entries());
59
59
  };
60
+ export const toVW = (px) => (px / (window.visualViewport?.width ?? window.innerWidth)) * 100;
61
+ export const toVH = (px) => (px / (window.visualViewport?.height ?? window.innerHeight)) * 100;
@@ -37,3 +37,7 @@ export interface MVD<T = number> {
37
37
  */
38
38
  density: T;
39
39
  }
40
+ export interface MinMax {
41
+ min: number;
42
+ max: number;
43
+ }
package/dist/string.d.ts CHANGED
@@ -101,3 +101,7 @@ export declare const toCapitalCaseMap: (str?: string) => string;
101
101
  * ```
102
102
  */
103
103
  export declare const repeat: (str: string, length: number, separator?: string) => string;
104
+ /**
105
+ * Создает на основе строки UUID по DJB2
106
+ */
107
+ export declare const toUUID: (key: string) => string;
package/dist/string.js CHANGED
@@ -101,3 +101,13 @@ export const toCapitalCaseMap = (str = "") => str.split(" ").map(toCapitalCase).
101
101
  * ```
102
102
  */
103
103
  export const repeat = (str, length, separator = "") => Array.from({ length }).fill(str).join(separator);
104
+ /**
105
+ * Создает на основе строки UUID по DJB2
106
+ */
107
+ export const toUUID = (key) => {
108
+ let hash = 5381; // DJB2
109
+ for (let i = 0; i < key.length; i++)
110
+ hash = ((hash << 5) + hash) ^ (key.codePointAt(i) ?? 0);
111
+ const hex = Math.trunc(hash).toString(16).padStart(8, "0");
112
+ return `${hex}-0000-0000-0000-000000000000`;
113
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nemigo/helpers",
3
- "version": "2.8.0",
3
+ "version": "2.8.3",
4
4
  "private": false,
5
5
  "license": "MPL-2.0",
6
6
  "author": {