@leexi/shared 0.3.8 → 0.3.9
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 +29 -29
- package/dist/module.json +3 -3
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -66,16 +66,16 @@ export default defineNuxtConfig({
|
|
|
66
66
|
- [Utils](#utils)
|
|
67
67
|
- [Records](#records)
|
|
68
68
|
- [set](#set)
|
|
69
|
-
- [omit](#omit)
|
|
70
69
|
- [pick](#pick)
|
|
70
|
+
- [omit](#omit)
|
|
71
71
|
- [Strings](#strings)
|
|
72
72
|
- [camelcase](#camelcase)
|
|
73
73
|
- [capitalize](#capitalize)
|
|
74
74
|
- [kebabcase](#kebabcase)
|
|
75
75
|
- [snakecase](#snakecase)
|
|
76
76
|
- [Objects](#objects)
|
|
77
|
-
- [deepDup](#deepdup)
|
|
78
77
|
- [isSame](#issame)
|
|
78
|
+
- [deepDup](#deepdup)
|
|
79
79
|
|
|
80
80
|
## Composables
|
|
81
81
|
### useLocalStorage
|
|
@@ -116,32 +116,32 @@ set(myObject, ['a', 'b', 'd'], 2);
|
|
|
116
116
|
console.log(myObject); // Output: { a: { b: { c: 1, d: 2 } } }
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
####
|
|
120
|
-
Creates a new object by
|
|
119
|
+
#### pick
|
|
120
|
+
Creates a new object by picking only the specified keys from the input record.
|
|
121
121
|
- Type
|
|
122
122
|
```ts
|
|
123
|
-
const
|
|
123
|
+
const pick: <T extends Record<string, unknown>, K extends (keyof T)[]>(record: T, keys: K) => Pick<T, K[number]>;
|
|
124
124
|
```
|
|
125
125
|
- Example
|
|
126
126
|
```ts
|
|
127
127
|
const myObject = { a: 1, b: 2, c: 3, d: 4 };
|
|
128
|
-
const
|
|
128
|
+
const pickedObject = pick(myObject, ['a', 'c']);
|
|
129
129
|
|
|
130
|
-
console.log(
|
|
130
|
+
console.log(pickedObject); // Output: { a: 1, c: 3 }
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
-
####
|
|
134
|
-
Creates a new object by
|
|
133
|
+
#### omit
|
|
134
|
+
Creates a new object by omitting the specified keys from the input record.
|
|
135
135
|
- Type
|
|
136
136
|
```ts
|
|
137
|
-
const
|
|
137
|
+
const omit: <T extends Record<string, unknown>, K extends (keyof T)[]>(record: T, keys: K) => Omit<T, K[number]>;
|
|
138
138
|
```
|
|
139
139
|
- Example
|
|
140
140
|
```ts
|
|
141
141
|
const myObject = { a: 1, b: 2, c: 3, d: 4 };
|
|
142
|
-
const
|
|
142
|
+
const omittedObject = omit(myObject, ['b', 'd']);
|
|
143
143
|
|
|
144
|
-
console.log(
|
|
144
|
+
console.log(omittedObject); // Output: { a: 1, c: 3 }
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
### Strings
|
|
@@ -197,6 +197,23 @@ console.log(snakecase('my_variable_name')); // Output: my_variable_name
|
|
|
197
197
|
```
|
|
198
198
|
|
|
199
199
|
### Objects
|
|
200
|
+
#### isSame
|
|
201
|
+
Checks if two objects are the same by comparing their JSON stringified representations.
|
|
202
|
+
Note: This method has limitations and may not accurately compare objects with different key orders, non-primitive values like functions or Dates, or circular references.
|
|
203
|
+
- Type
|
|
204
|
+
```ts
|
|
205
|
+
const isSame: (a: object, b: object) => boolean;
|
|
206
|
+
```
|
|
207
|
+
- Example
|
|
208
|
+
```ts
|
|
209
|
+
const obj1 = { a: 1, b: 2 };
|
|
210
|
+
const obj2 = { a: 1, b: 2 };
|
|
211
|
+
const obj3 = { b: 2, a: 1 };
|
|
212
|
+
|
|
213
|
+
console.log(isSame(obj1, obj2)); // Output: true
|
|
214
|
+
console.log(isSame(obj1, obj3)); // Output: false (due to key order difference in JSON stringification)
|
|
215
|
+
```
|
|
216
|
+
|
|
200
217
|
#### deepDup
|
|
201
218
|
Creates a deep duplicate of an object, array, or Set.
|
|
202
219
|
It handles nested objects, arrays, and Sets but does not handle functions, Dates, or circular references.
|
|
@@ -215,20 +232,3 @@ console.log(originalObject.b === duplicatedObject.b); // Output: false
|
|
|
215
232
|
console.log(originalObject.b.d === duplicatedObject.b.d); // Output: false
|
|
216
233
|
console.log(originalObject.e === duplicatedObject.e); // Output: false
|
|
217
234
|
```
|
|
218
|
-
|
|
219
|
-
#### isSame
|
|
220
|
-
Checks if two objects are the same by comparing their JSON stringified representations.
|
|
221
|
-
Note: This method has limitations and may not accurately compare objects with different key orders, non-primitive values like functions or Dates, or circular references.
|
|
222
|
-
- Type
|
|
223
|
-
```ts
|
|
224
|
-
const isSame: (a: object, b: object) => boolean;
|
|
225
|
-
```
|
|
226
|
-
- Example
|
|
227
|
-
```ts
|
|
228
|
-
const obj1 = { a: 1, b: 2 };
|
|
229
|
-
const obj2 = { a: 1, b: 2 };
|
|
230
|
-
const obj3 = { b: 2, a: 1 };
|
|
231
|
-
|
|
232
|
-
console.log(isSame(obj1, obj2)); // Output: true
|
|
233
|
-
console.log(isSame(obj1, obj3)); // Output: false (due to key order difference in JSON stringification)
|
|
234
|
-
```
|
package/dist/module.json
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"license": "UNLICENSED",
|
|
3
3
|
"name": "@leexi/shared",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.9",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./composables": {
|
|
8
8
|
"import": "./dist/runtime/composables/index.js",
|
|
@@ -46,24 +46,24 @@
|
|
|
46
46
|
"tsc": "vue-tsc --noEmit"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@stylistic/eslint-plugin": "^5.
|
|
49
|
+
"@stylistic/eslint-plugin": "^5.2.2",
|
|
50
50
|
"@types/eslint-plugin-tailwindcss": "^3.17.0",
|
|
51
|
-
"eslint": "^9.
|
|
52
|
-
"eslint-plugin-tailwindcss": "^3.18.
|
|
53
|
-
"eslint-plugin-vue": "^10.
|
|
51
|
+
"eslint": "^9.32.0",
|
|
52
|
+
"eslint-plugin-tailwindcss": "^3.18.2",
|
|
53
|
+
"eslint-plugin-vue": "^10.4.0",
|
|
54
54
|
"globals": "^16.2.0",
|
|
55
55
|
"typescript": "^5.8.3",
|
|
56
|
-
"typescript-eslint": "^8.
|
|
56
|
+
"typescript-eslint": "^8.38.0",
|
|
57
57
|
"vue-eslint-parser": "^10.2.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@nuxt/module-builder": "^1.0.
|
|
60
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
61
61
|
"@nuxt/test-utils": "^3.19.2",
|
|
62
62
|
"@types/node": "^22.16.0",
|
|
63
63
|
"happy-dom": "^18.0.1",
|
|
64
64
|
"nuxt": "^3.17.6",
|
|
65
65
|
"tailwindcss": "<4.0.0",
|
|
66
66
|
"vitest": "^3.2.4",
|
|
67
|
-
"vue-tsc": "^
|
|
67
|
+
"vue-tsc": "^3.0.4"
|
|
68
68
|
}
|
|
69
69
|
}
|