@leexi/shared 0.7.2 → 0.7.5

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/README.md CHANGED
@@ -144,10 +144,10 @@ const filterMap: <T>(items: T[], callback: (_item: T) => unknown) => unknown[];
144
144
  ```
145
145
  - Example
146
146
  ```ts
147
- const items = [0, 1];
148
- const foos = filterMap(records, foo => foo2);
147
+ const items = [1, 2];
148
+ const foos = filterMap(items, foo => (foo % 2 === 0) && (2 / foo));
149
149
 
150
- console.log(foos); // Output: [2]
150
+ console.log(foos); // Output: [1]
151
151
  ```
152
152
 
153
153
  #### groupBy
@@ -259,10 +259,13 @@ Returns a random integer greater than or equal to `min` and less than or equal t
259
259
  If the min is bigger than the max then NaN is returned.
260
260
  - Type
261
261
  ```ts
262
- const rand: (max: number, min?: number) => number;
262
+ const rand: (max?: number, min?: number) => number;
263
263
  ```
264
264
  - Example
265
265
  ```ts
266
+ const randDefault = rand();
267
+ console.log(randDefault); // Output: 676942
268
+
266
269
  const randOne = rand(2);
267
270
  console.log(randOne); // Output: 1
268
271
 
@@ -28,20 +28,25 @@ const config = [
28
28
  "no-console": "error",
29
29
  "no-nested-ternary": "error",
30
30
  "no-shadow": "error",
31
- "no-unused-vars": ["error", {
32
- argsIgnorePattern: "^_",
33
- destructuredArrayIgnorePattern: "^_",
34
- ignoreRestSiblings: true
35
- }],
31
+ "no-unused-vars": [
32
+ "error",
33
+ {
34
+ argsIgnorePattern: "^_",
35
+ destructuredArrayIgnorePattern: "^_",
36
+ ignoreRestSiblings: true
37
+ }
38
+ ],
36
39
  "padding-line-between-statements": [
37
40
  "error",
38
41
  { blankLine: "always", next: "*", prev: "if" },
39
42
  { blankLine: "any", next: "if", prev: "if" }
40
43
  ],
41
- "prefer-const": ["error", {
42
- destructuring: "all"
43
- }],
44
+ "prefer-const": [
45
+ "error",
46
+ { destructuring: "all" }
47
+ ],
44
48
  "prefer-template": "error",
49
+ "@stylistic/array-bracket-newline": ["error", { multiline: true }],
45
50
  "@stylistic/array-bracket-spacing": ["error", "never"],
46
51
  "@stylistic/arrow-parens": ["error", "as-needed"],
47
52
  "@stylistic/arrow-spacing": "error",
@@ -50,16 +55,19 @@ const config = [
50
55
  "@stylistic/comma-spacing": "error",
51
56
  "@stylistic/eol-last": ["error", "always"],
52
57
  "@stylistic/function-call-spacing": "error",
53
- "@stylistic/indent": ["error", 2, {
54
- SwitchCase: 1
55
- }],
58
+ "@stylistic/indent": [
59
+ "error",
60
+ 2,
61
+ { SwitchCase: 1 }
62
+ ],
56
63
  "@stylistic/key-spacing": "error",
57
64
  "@stylistic/keyword-spacing": "error",
58
65
  "@stylistic/multiline-ternary": ["error", "never"],
59
66
  "@stylistic/no-multi-spaces": "error",
60
- "@stylistic/no-multiple-empty-lines": ["error", {
61
- max: 1
62
- }],
67
+ "@stylistic/no-multiple-empty-lines": [
68
+ "error",
69
+ { max: 1 }
70
+ ],
63
71
  "@stylistic/no-trailing-spaces": "error",
64
72
  "@stylistic/object-curly-spacing": ["error", "always"],
65
73
  "@stylistic/quote-props": ["error", "consistent-as-needed"],
@@ -73,27 +81,32 @@ const config = [
73
81
  "@stylistic/spaced-comment": "error",
74
82
  "@stylistic/template-curly-spacing": ["error", "never"],
75
83
  "@typescript-eslint/no-unused-expressions": "off",
76
- "@typescript-eslint/no-unused-vars": ["error", {
77
- argsIgnorePattern: "^_",
78
- destructuredArrayIgnorePattern: "^_",
79
- ignoreRestSiblings: true
80
- }]
84
+ "@typescript-eslint/no-unused-vars": [
85
+ "error",
86
+ {
87
+ argsIgnorePattern: "^_",
88
+ destructuredArrayIgnorePattern: "^_",
89
+ ignoreRestSiblings: true
90
+ }
91
+ ]
81
92
  }
82
93
  },
83
94
  // sort-keys
84
95
  {
85
96
  files: ["**/*.config.{js,ts}", "**/locales/**/*.js"],
86
97
  rules: {
87
- "sort-keys-plus/sort-keys": ["error", "asc", {
88
- allowLineSeparatedGroups: true,
89
- natural: true
90
- }]
98
+ "sort-keys-plus/sort-keys": [
99
+ "error",
100
+ "asc",
101
+ {
102
+ allowLineSeparatedGroups: true,
103
+ natural: true
104
+ }
105
+ ]
91
106
  }
92
107
  },
93
108
  {
94
- ignores: [
95
- "node_modules/"
96
- ]
109
+ ignores: ["node_modules/"]
97
110
  }
98
111
  ];
99
112
  export default config;
@@ -16,26 +16,34 @@ const config = [
16
16
  rules: {
17
17
  "@stylistic/indent": "off",
18
18
  "tailwindcss/no-custom-classname": "error",
19
+ "vue/array-bracket-newline": ["error", { multiline: true }],
19
20
  "vue/array-bracket-spacing": ["error", "never"],
20
21
  "vue/arrow-spacing": "error",
21
- "vue/attributes-order": ["error", {
22
- alphabetical: true
23
- }],
22
+ "vue/attributes-order": [
23
+ "error",
24
+ { alphabetical: true }
25
+ ],
24
26
  "vue/block-spacing": "error",
25
27
  "vue/comma-dangle": ["error", "always-multiline"],
26
28
  "vue/comma-spacing": "error",
27
- "vue/component-name-in-template-casing": ["error", "PascalCase", {
28
- registeredComponentsOnly: false
29
- }],
29
+ "vue/component-name-in-template-casing": [
30
+ "error",
31
+ "PascalCase",
32
+ { registeredComponentsOnly: false }
33
+ ],
30
34
  "vue/custom-event-name-casing": "error",
31
- "vue/define-macros-order": ["error", {
32
- defineExposeLast: true,
33
- order: ["definePage", "defineOptions", "defineProps", "defineEmits", "defineSlots", "defineModel"]
34
- }],
35
+ "vue/define-macros-order": [
36
+ "error",
37
+ {
38
+ defineExposeLast: true,
39
+ order: ["definePage", "defineOptions", "defineProps", "defineEmits", "defineSlots", "defineModel"]
40
+ }
41
+ ],
35
42
  "vue/eqeqeq": ["error", "smart"],
36
- "vue/first-attribute-linebreak": ["error", {
37
- singleline: "beside"
38
- }],
43
+ "vue/first-attribute-linebreak": [
44
+ "error",
45
+ { singleline: "beside" }
46
+ ],
39
47
  "vue/func-call-spacing": "error",
40
48
  "vue/key-spacing": "error",
41
49
  "vue/multi-word-component-names": "off",
@@ -47,20 +55,28 @@ const config = [
47
55
  "vue/no-unused-refs": "error",
48
56
  "vue/object-curly-spacing": ["error", "always"],
49
57
  "vue/padding-line-between-blocks": "error",
58
+ "vue/padding-line-between-tags": [
59
+ "error",
60
+ [{ blankLine: "always", next: "*", prev: "*" }]
61
+ ],
50
62
  "vue/prefer-separate-static-class": "error",
51
63
  "vue/prefer-template": "error",
52
64
  "vue/prefer-use-template-ref": "error",
53
65
  "vue/quote-props": ["error", "consistent-as-needed"],
54
66
  "vue/require-default-prop": "off",
55
67
  "vue/require-macro-variable-name": "error",
56
- "vue/script-indent": ["error", 2, {
57
- switchCase: 1
58
- }],
68
+ "vue/script-indent": [
69
+ "error",
70
+ 2,
71
+ { switchCase: 1 }
72
+ ],
59
73
  "vue/space-in-parens": ["error", "never"],
60
74
  "vue/template-curly-spacing": ["error", "never"],
61
- "vue/v-bind-style": ["error", "shorthand", {
62
- sameNameShorthand: "always"
63
- }]
75
+ "vue/v-bind-style": [
76
+ "error",
77
+ "shorthand",
78
+ { sameNameShorthand: "always" }
79
+ ]
64
80
  }
65
81
  },
66
82
  {
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "configKey": "leexi",
3
3
  "name": "@leexi/shared",
4
- "version": "0.7.2",
4
+ "version": "0.7.5",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -5,11 +5,11 @@ export const useLocalStorage = (key, defaultValue) => {
5
5
  throw new Error(`[useLocalStorage]: prefer camelCase fro key \`${key}\``);
6
6
  }
7
7
  const _findLocalStorageValue = () => {
8
- if (localStorage?.getItem(key)) {
8
+ if (_tryLocalStorage()?.getItem(key)) {
9
9
  return localStorage.getItem(key);
10
10
  }
11
11
  for (const caseKey of [key, kebabcase(key), snakecase(key)]) {
12
- if (localStorage?.getItem(caseKey)) {
12
+ if (_tryLocalStorage()?.getItem(caseKey)) {
13
13
  localStorage.setItem(key, localStorage.getItem(caseKey));
14
14
  localStorage.removeItem(caseKey);
15
15
  return localStorage.getItem(key);
@@ -26,12 +26,19 @@ export const useLocalStorage = (key, defaultValue) => {
26
26
  return _parseLocalStorageValue();
27
27
  }
28
28
  };
29
+ const _tryLocalStorage = () => {
30
+ try {
31
+ return localStorage;
32
+ } catch {
33
+ return null;
34
+ }
35
+ };
29
36
  const data = useState(key, _parseLocalStorageValue);
30
37
  watch(data, () => {
31
38
  if (data.value) {
32
- localStorage?.setItem(key, JSON.stringify(data.value));
39
+ _tryLocalStorage()?.setItem(key, JSON.stringify(data.value));
33
40
  } else {
34
- localStorage?.removeItem(key);
41
+ _tryLocalStorage()?.removeItem(key);
35
42
  }
36
43
  }, { deep: true, immediate: true });
37
44
  return data;
@@ -7,9 +7,9 @@
7
7
  * @returns An array of filtered items mapped to the given callback.
8
8
  *
9
9
  * @example
10
- * const items = [0, 1];
11
- * const foos = filterMap(records, foo => foo * 2);
10
+ * const items = [1, 2];
11
+ * const foos = filterMap(items, foo => (foo % 2 === 0) && (2 / foo));
12
12
  *
13
- * console.log(foos); // Output: [2]
13
+ * console.log(foos); // Output: [1]
14
14
  */
15
15
  export declare const filterMap: <T>(items: T[], callback: (_item: T) => unknown) => unknown[];
@@ -2,15 +2,18 @@
2
2
  * Returns a random integer greater than or equal to `min` and less than or equal to `max`.
3
3
  * If the min is bigger than the max then NaN is returned.
4
4
  *
5
- * @param max A number.
5
+ * @param max A number(defaults to 2147483647).
6
6
  * @param min A number (defaults to 0).
7
7
  * @returns A random number within the range.
8
8
  *
9
9
  * @example
10
+ * const randDefault = rand();
11
+ * console.log(randDefault); // Output: 676942
12
+ *
10
13
  * const randOne = rand(2);
11
14
  * console.log(randOne); // Output: 1
12
15
  *
13
16
  * const randTwo = rand(2, -2);
14
17
  * console.log(randTwo); // Output: -1
15
18
  */
16
- export declare const rand: (max: number, min?: number) => number;
19
+ export declare const rand: (max?: number, min?: number) => number;
@@ -1 +1 @@
1
- export const rand = (max, min = 0) => Math.floor(Math.random() * (max - min + 1)) + min;
1
+ export const rand = (max = 2147483647, min = 0) => Math.floor(Math.random() * (max - min + 1)) + min;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "license": "UNLICENSED",
3
3
  "name": "@leexi/shared",
4
4
  "type": "module",
5
- "version": "0.7.2",
5
+ "version": "0.7.5",
6
6
  "exports": {
7
7
  "./composables": {
8
8
  "import": "./dist/runtime/composables/index.js",
@@ -48,23 +48,23 @@
48
48
  "dependencies": {
49
49
  "@stylistic/eslint-plugin": "5.6.1",
50
50
  "@types/eslint-plugin-tailwindcss": "3.17.0",
51
- "eslint": "9.39.1",
51
+ "eslint": "9.39.2",
52
52
  "eslint-plugin-sort-keys-plus": "1.5.0",
53
53
  "eslint-plugin-tailwindcss": "3.18.2",
54
54
  "eslint-plugin-vue": "10.6.2",
55
- "globals": "16.5.0",
55
+ "globals": "17.0.0",
56
56
  "typescript": "5.9.3",
57
- "typescript-eslint": "8.48.1",
57
+ "typescript-eslint": "8.51.0",
58
58
  "vue-eslint-parser": "10.2.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@nuxt/module-builder": "1.0.2",
62
- "@nuxt/test-utils": "3.20.1",
62
+ "@nuxt/test-utils": "3.21.0",
63
63
  "@types/node": "<23.0.0",
64
64
  "happy-dom": "20.0.11",
65
65
  "nuxt": "4.2.2",
66
66
  "tailwindcss": "<4.0.0",
67
- "vitest": "4.0.14",
68
- "vue-tsc": "3.1.5"
67
+ "vitest": "4.0.16",
68
+ "vue-tsc": "3.2.1"
69
69
  }
70
70
  }