@vnejs/uis.utils 0.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 ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@vnejs/uis.utils",
3
+ "version": "0.1.0",
4
+ "main": "src/index.js",
5
+ "scripts": {
6
+ "publish:major:plugin": "npm run publish:major",
7
+ "publish:minor:plugin": "npm run publish:minor",
8
+ "publish:patch:plugin": "npm run publish:patch",
9
+ "publish:major": "npm version major && npm publish --access public",
10
+ "publish:minor": "npm version minor && npm publish --access public",
11
+ "publish:patch": "npm version patch && npm publish --access public"
12
+ }
13
+ }
package/src/cn.js ADDED
@@ -0,0 +1,6 @@
1
+ const getModifClassName = (prefix, key, value) => (typeof value === "string" ? `${prefix}_${key}_${value}` : value ? `${prefix}_${key}` : "");
2
+
3
+ const wrapWithModificator = (className, obj) =>
4
+ Object.entries(obj).reduce((acc, [key, value]) => acc + getModifClassName(` ${className}`, key, value), [className]);
5
+
6
+ const cn = (blockName) => (elementName, obj) => wrapWithModificator(elementName ? `${blockName}-${elementName}` : `${blockName}`, obj);
@@ -0,0 +1,23 @@
1
+ export const HEIGHT = 2160;
2
+ export const WIDTH = 3840;
3
+ export const HEIGHT_ARRAY = [];
4
+ export const WIDTH_ARRAY = [];
5
+
6
+ const proccess = (i, value, arr) => {
7
+ if (value % i === 0) arr.push(i);
8
+ if (value / i < i) {
9
+ const maxLength = arr.length;
10
+
11
+ arr.forEach((_, j) => arr.push(Math.round(value / arr[maxLength - j - 1])));
12
+ arr.push(value);
13
+
14
+ return true;
15
+ }
16
+
17
+ return false;
18
+ };
19
+
20
+ for (let i = 2; ; i++) if (proccess(i, HEIGHT, HEIGHT_ARRAY)) break;
21
+ for (let i = 2; ; i++) if (proccess(i, WIDTH, WIDTH_ARRAY)) break;
22
+
23
+ export const LENGTH_ARRAY = [...new Set([...HEIGHT_ARRAY, ...WIDTH_ARRAY]).values()].sort((i, j) => i - j);
@@ -0,0 +1,11 @@
1
+ import { LENGTH_ARRAY } from "./getHeightArray";
2
+
3
+ export const getVneLength = (size) => {
4
+ for (let i = 0; i < LENGTH_ARRAY.length; i++) {
5
+ const result = LENGTH_ARRAY[LENGTH_ARRAY.length - i - 1];
6
+
7
+ if (size % result === 0) return { count: Math.round(size / result), length: result };
8
+ }
9
+
10
+ return { isEmpty: true };
11
+ };
package/src/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./cn";
2
+ export * from "./getVneLength";
3
+ export * from "./getHeightArray";