@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.
- package/dist/html/index.d.ts +2 -0
- package/dist/html/index.js +2 -0
- package/dist/phymath/types.d.ts +4 -0
- package/dist/string.d.ts +4 -0
- package/dist/string.js +10 -0
- package/package.json +1 -1
package/dist/html/index.d.ts
CHANGED
|
@@ -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;
|
package/dist/html/index.js
CHANGED
|
@@ -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;
|
package/dist/phymath/types.d.ts
CHANGED
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
|
+
};
|