@leexi/shared 0.7.1 → 0.7.2
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 +33 -0
- package/dist/eslint/base.eslint.config.mjs +1 -0
- package/dist/module.json +1 -1
- package/dist/runtime/utils/array/filterMap.d.ts +15 -0
- package/dist/runtime/utils/array/filterMap.js +7 -0
- package/dist/runtime/utils/array/index.d.ts +1 -0
- package/dist/runtime/utils/array/index.js +1 -0
- package/dist/runtime/utils/number/rand.d.ts +16 -0
- package/dist/runtime/utils/number/rand.js +1 -0
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@ export default defineNuxtConfig({
|
|
|
66
66
|
- [Utils](#utils)
|
|
67
67
|
- [Array](#array)
|
|
68
68
|
- [castArray](#castarray)
|
|
69
|
+
- [filterMap](#filtermap)
|
|
69
70
|
- [groupBy](#groupby)
|
|
70
71
|
- [joinBy](#joinby)
|
|
71
72
|
- [partition](#partition)
|
|
@@ -80,6 +81,7 @@ export default defineNuxtConfig({
|
|
|
80
81
|
- [Function](#function)
|
|
81
82
|
- [debounce](#debounce)
|
|
82
83
|
- [Number](#number)
|
|
84
|
+
- [rand](#rand)
|
|
83
85
|
- [toPadStart](#topadstart)
|
|
84
86
|
- [Objects](#objects)
|
|
85
87
|
- [deepDup](#deepdup)
|
|
@@ -133,6 +135,21 @@ console.log(localStorage.userSetting); // Output: '{"theme":"dark","notification
|
|
|
133
135
|
|
|
134
136
|
```
|
|
135
137
|
|
|
138
|
+
#### filterMap
|
|
139
|
+
Returns a new array containing the truthy results (everything except false, '', 0, undefined and null) of running the
|
|
140
|
+
given callback for every item.
|
|
141
|
+
- Type
|
|
142
|
+
```ts
|
|
143
|
+
const filterMap: <T>(items: T[], callback: (_item: T) => unknown) => unknown[];
|
|
144
|
+
```
|
|
145
|
+
- Example
|
|
146
|
+
```ts
|
|
147
|
+
const items = [0, 1];
|
|
148
|
+
const foos = filterMap(records, foo => foo2);
|
|
149
|
+
|
|
150
|
+
console.log(foos); // Output: [2]
|
|
151
|
+
```
|
|
152
|
+
|
|
136
153
|
#### groupBy
|
|
137
154
|
- Type
|
|
138
155
|
```ts
|
|
@@ -237,6 +254,22 @@ console.log(uniq); // Output: [true, false, 1, 2, 'foo', 'bar']
|
|
|
237
254
|
```
|
|
238
255
|
|
|
239
256
|
### Number
|
|
257
|
+
#### rand
|
|
258
|
+
Returns a random integer greater than or equal to `min` and less than or equal to `max`.
|
|
259
|
+
If the min is bigger than the max then NaN is returned.
|
|
260
|
+
- Type
|
|
261
|
+
```ts
|
|
262
|
+
const rand: (max: number, min?: number) => number;
|
|
263
|
+
```
|
|
264
|
+
- Example
|
|
265
|
+
```ts
|
|
266
|
+
const randOne = rand(2);
|
|
267
|
+
console.log(randOne); // Output: 1
|
|
268
|
+
|
|
269
|
+
const randTwo = rand(2, -2);
|
|
270
|
+
console.log(randTwo); // Output: -1
|
|
271
|
+
```
|
|
272
|
+
|
|
240
273
|
#### toPadStart
|
|
241
274
|
- Type
|
|
242
275
|
```ts
|
package/dist/module.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a new array containing the truthy results (everything except false, '', 0, undefined and null) of running the
|
|
3
|
+
* given callback for every item.
|
|
4
|
+
*
|
|
5
|
+
* @param items An array of items.
|
|
6
|
+
* @param callback A callback returning the mapped result.
|
|
7
|
+
* @returns An array of filtered items mapped to the given callback.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const items = [0, 1];
|
|
11
|
+
* const foos = filterMap(records, foo => foo * 2);
|
|
12
|
+
*
|
|
13
|
+
* console.log(foos); // Output: [2]
|
|
14
|
+
*/
|
|
15
|
+
export declare const filterMap: <T>(items: T[], callback: (_item: T) => unknown) => unknown[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a random integer greater than or equal to `min` and less than or equal to `max`.
|
|
3
|
+
* If the min is bigger than the max then NaN is returned.
|
|
4
|
+
*
|
|
5
|
+
* @param max A number.
|
|
6
|
+
* @param min A number (defaults to 0).
|
|
7
|
+
* @returns A random number within the range.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const randOne = rand(2);
|
|
11
|
+
* console.log(randOne); // Output: 1
|
|
12
|
+
*
|
|
13
|
+
* const randTwo = rand(2, -2);
|
|
14
|
+
* console.log(randTwo); // Output: -1
|
|
15
|
+
*/
|
|
16
|
+
export declare const rand: (max: number, min?: number) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const rand = (max, 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.
|
|
5
|
+
"version": "0.7.2",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./composables": {
|
|
8
8
|
"import": "./dist/runtime/composables/index.js",
|
|
@@ -46,25 +46,25 @@
|
|
|
46
46
|
"tsc": "vue-tsc --noEmit"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@stylistic/eslint-plugin": "
|
|
50
|
-
"@types/eslint-plugin-tailwindcss": "
|
|
51
|
-
"eslint": "
|
|
52
|
-
"eslint-plugin-sort-keys-plus": "
|
|
53
|
-
"eslint-plugin-tailwindcss": "
|
|
54
|
-
"eslint-plugin-vue": "
|
|
55
|
-
"globals": "
|
|
56
|
-
"typescript": "
|
|
57
|
-
"typescript-eslint": "
|
|
58
|
-
"vue-eslint-parser": "
|
|
49
|
+
"@stylistic/eslint-plugin": "5.6.1",
|
|
50
|
+
"@types/eslint-plugin-tailwindcss": "3.17.0",
|
|
51
|
+
"eslint": "9.39.1",
|
|
52
|
+
"eslint-plugin-sort-keys-plus": "1.5.0",
|
|
53
|
+
"eslint-plugin-tailwindcss": "3.18.2",
|
|
54
|
+
"eslint-plugin-vue": "10.6.2",
|
|
55
|
+
"globals": "16.5.0",
|
|
56
|
+
"typescript": "5.9.3",
|
|
57
|
+
"typescript-eslint": "8.48.1",
|
|
58
|
+
"vue-eslint-parser": "10.2.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@nuxt/module-builder": "
|
|
62
|
-
"@nuxt/test-utils": "
|
|
61
|
+
"@nuxt/module-builder": "1.0.2",
|
|
62
|
+
"@nuxt/test-utils": "3.20.1",
|
|
63
63
|
"@types/node": "<23.0.0",
|
|
64
|
-
"happy-dom": "
|
|
65
|
-
"nuxt": "
|
|
64
|
+
"happy-dom": "20.0.11",
|
|
65
|
+
"nuxt": "4.2.2",
|
|
66
66
|
"tailwindcss": "<4.0.0",
|
|
67
|
-
"vitest": "
|
|
68
|
-
"vue-tsc": "
|
|
67
|
+
"vitest": "4.0.14",
|
|
68
|
+
"vue-tsc": "3.1.5"
|
|
69
69
|
}
|
|
70
70
|
}
|