utils-lib-js 2.0.14 → 2.0.15
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.en.md +95 -82
- package/README.md +13 -0
- package/dist/bundle/base.d.ts +2 -0
- package/dist/bundle/index.d.ts +1 -0
- package/dist/bundle/index.js +3 -15
- package/dist/cjs/base.d.ts +2 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +353 -6408
- package/dist/esm/base.d.ts +2 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +308 -6365
- package/dist/umd/base.d.ts +2 -0
- package/dist/umd/index.d.ts +1 -0
- package/dist/umd/index.js +353 -6408
- package/package.json +12 -12
package/README.en.md
CHANGED
|
@@ -62,9 +62,9 @@ With reference to https://gitee.com/DieHunter/utils-lib-js/blob/master/src/types
|
|
|
62
62
|
|
|
63
63
|
Generates random integers within the specified range.
|
|
64
64
|
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
65
|
+
- `min` : indicates the minimum value (including).
|
|
66
|
+
- `max` : indicates the maximum value (inclusive).
|
|
67
|
+
- `bool` : Indicates whether the maximum value is contained. The default value is false.
|
|
68
68
|
|
|
69
69
|
```javascript
|
|
70
70
|
const randomNumber = randomNum(1, 10);
|
|
@@ -75,7 +75,7 @@ console.log(randomNumber); // Generates a random integer between 1 and 10
|
|
|
75
75
|
|
|
76
76
|
Parses URL query parameters into objects.
|
|
77
77
|
|
|
78
|
-
-
|
|
78
|
+
- `url` : indicates the URL containing the query parameter.
|
|
79
79
|
|
|
80
80
|
```javascript
|
|
81
81
|
const url = "https://example.com/path?param1=value1¶m2=value2";
|
|
@@ -88,8 +88,8 @@ console.log(params);
|
|
|
88
88
|
|
|
89
89
|
Converts the object to a URL query parameter and concatenates it with the original URL.
|
|
90
90
|
|
|
91
|
-
-
|
|
92
|
-
-
|
|
91
|
+
- `url` : indicates the original URL.
|
|
92
|
+
- `query` : object containing query parameters.
|
|
93
93
|
|
|
94
94
|
```javascript
|
|
95
95
|
const url = "https://example.com/path";
|
|
@@ -103,7 +103,7 @@ console.log(newUrl);
|
|
|
103
103
|
|
|
104
104
|
Get the type of data.
|
|
105
105
|
|
|
106
|
-
-
|
|
106
|
+
- `data` : indicates the data to be checked.
|
|
107
107
|
|
|
108
108
|
```javascript
|
|
109
109
|
const dataType = getType("Hello, World!");
|
|
@@ -114,8 +114,8 @@ console.log(dataType); // Output: string
|
|
|
114
114
|
|
|
115
115
|
Check whether the data type is in the whitelist.
|
|
116
116
|
|
|
117
|
-
-
|
|
118
|
-
-
|
|
117
|
+
- `data` : indicates the data to be checked.
|
|
118
|
+
- `whiteList` : indicates the list of allowed data types.
|
|
119
119
|
|
|
120
120
|
```javascript
|
|
121
121
|
const data = 42;
|
|
@@ -124,15 +124,28 @@ const isTypeAllowed = getTypeByList(data, allowedTypes);
|
|
|
124
124
|
console.log(isTypeAllowed); // Output: true
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
+
##### 6. `toKebabCase(camelCase: string, separator: string = "-"): string`
|
|
128
|
+
|
|
129
|
+
The hump name is converted to a hyphenated name
|
|
130
|
+
|
|
131
|
+
- `camelCase` : hump type variable
|
|
132
|
+
- `separator` : indicates the separator
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
const camelCase = "fontSize";
|
|
136
|
+
const kebabCase = toKebabCase(camelCase);
|
|
137
|
+
console.log(kebabCase); // Output: font-size
|
|
138
|
+
```
|
|
139
|
+
|
|
127
140
|
#### object module
|
|
128
141
|
|
|
129
142
|
##### 1. `getValue(object: object, key: string, defaultValue: any = ''): any`
|
|
130
143
|
|
|
131
144
|
Gets the value of the specified path in the object.
|
|
132
145
|
|
|
133
|
-
-
|
|
134
|
-
-
|
|
135
|
-
-
|
|
146
|
+
- `object` : indicates the target object.
|
|
147
|
+
- `key` : the path to the value to be obtained.
|
|
148
|
+
- `defaultValue` : Default value, returned if the path does not exist.
|
|
136
149
|
|
|
137
150
|
```javascript
|
|
138
151
|
const obj = { a: { b: { c: 42 } } };
|
|
@@ -144,9 +157,9 @@ console.log(value); // Output: 42
|
|
|
144
157
|
|
|
145
158
|
Sets the value of the specified path in the object.
|
|
146
159
|
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
-
|
|
160
|
+
- `object` : indicates the target object.
|
|
161
|
+
- `key` : path to the value to be set.
|
|
162
|
+
- `value` : indicates the value to be set.
|
|
150
163
|
|
|
151
164
|
```javascript
|
|
152
165
|
const obj = { a: { b: { c: 42 } } };
|
|
@@ -158,9 +171,9 @@ console.log(obj); // Output: {a: {b: {c: 42, d: 'new value'}}}
|
|
|
158
171
|
|
|
159
172
|
Mixes the properties of the source object into the target object.
|
|
160
173
|
|
|
161
|
-
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
174
|
+
- `target` : indicates the target object.
|
|
175
|
+
- `source` : indicates the source object.
|
|
176
|
+
- `overwrite` : Whether to overwrite an existing attribute. The default is' false '.
|
|
164
177
|
|
|
165
178
|
```javascript
|
|
166
179
|
const target = { a: 1 };
|
|
@@ -173,7 +186,7 @@ console.log(result); // Output: {a: 1, b: 2}
|
|
|
173
186
|
|
|
174
187
|
Inverts the key-value pair of an enumeration object.
|
|
175
188
|
|
|
176
|
-
-
|
|
189
|
+
- `target` : enumeration object to be reversed.
|
|
177
190
|
|
|
178
191
|
```javascript
|
|
179
192
|
const enumObj = { key1: "value1", key2: "value2" };
|
|
@@ -185,8 +198,8 @@ console.log(invertedEnum); // Output: {value1: 'key1', value2: 'key2'}
|
|
|
185
198
|
|
|
186
199
|
Check whether the value is of a non-object type.
|
|
187
200
|
|
|
188
|
-
-
|
|
189
|
-
-
|
|
201
|
+
- `source` : indicates the value to be checked.
|
|
202
|
+
- `type` : indicates the data type.
|
|
190
203
|
|
|
191
204
|
```javascript
|
|
192
205
|
const result = isNotObject(42, "number");
|
|
@@ -197,7 +210,7 @@ console.log(result); // Output: false
|
|
|
197
210
|
|
|
198
211
|
Deep clone object.
|
|
199
212
|
|
|
200
|
-
-
|
|
213
|
+
- `target` : indicates the object to be cloned.
|
|
201
214
|
|
|
202
215
|
```javascript
|
|
203
216
|
const obj = { a: { b: { c: 42 } } };
|
|
@@ -209,8 +222,8 @@ console.log(clonedObj); // Output: {a: {b: {c: 42}}}
|
|
|
209
222
|
|
|
210
223
|
Creates an object of a specific type based on its type.
|
|
211
224
|
|
|
212
|
-
-
|
|
213
|
-
-
|
|
225
|
+
- `type` : indicates the type of the object to be created.
|
|
226
|
+
- `source` : initializes the data of the object.
|
|
214
227
|
|
|
215
228
|
```javascript
|
|
216
229
|
const array = createObjectVariable("array", [1, 2, 3]);
|
|
@@ -221,7 +234,7 @@ console.log(array); // Output: [1, 2, 3]
|
|
|
221
234
|
|
|
222
235
|
Create objects using a prototype chain.
|
|
223
236
|
|
|
224
|
-
-
|
|
237
|
+
- `source` : prototype object.
|
|
225
238
|
|
|
226
239
|
```javascript
|
|
227
240
|
const protoObj = { a: 1 };
|
|
@@ -233,8 +246,8 @@ console.log(newObj.a); // Output: 1
|
|
|
233
246
|
|
|
234
247
|
Inherit the prototype chain.
|
|
235
248
|
|
|
236
|
-
-
|
|
237
|
-
-
|
|
249
|
+
- `source` : prototype chain of the parent object.
|
|
250
|
+
- `target` : constructor of the child object.
|
|
238
251
|
|
|
239
252
|
```javascript
|
|
240
253
|
function Parent() {}
|
|
@@ -252,9 +265,9 @@ childInstance.method(); // Output: Hello from parent
|
|
|
252
265
|
|
|
253
266
|
Gets a singleton instance of a class.
|
|
254
267
|
|
|
255
|
-
-
|
|
256
|
-
-
|
|
257
|
-
-
|
|
268
|
+
- `classProto` : The prototype chain of the class.
|
|
269
|
+
- `overwrite` : Whether to overwrite an existing instance. The default is' false '.
|
|
270
|
+
- `params` : arguments to the class constructor.
|
|
258
271
|
|
|
259
272
|
```javascript
|
|
260
273
|
class Singleton {
|
|
@@ -273,7 +286,7 @@ console.log(instance1 === instance2); // Output: false
|
|
|
273
286
|
|
|
274
287
|
Add a decorator to the class.
|
|
275
288
|
|
|
276
|
-
-
|
|
289
|
+
- `params` : properties and methods to add.
|
|
277
290
|
|
|
278
291
|
```javascript
|
|
279
292
|
@classDecorator({
|
|
@@ -291,7 +304,7 @@ instance.additionalMethod(); // Output: Additional method
|
|
|
291
304
|
|
|
292
305
|
Converts a JSON string to an object.
|
|
293
306
|
|
|
294
|
-
-
|
|
307
|
+
- `target` : JSON string to be converted.
|
|
295
308
|
|
|
296
309
|
```javascript
|
|
297
310
|
const jsonString = '{"key": "value"}';
|
|
@@ -303,7 +316,7 @@ console.log(jsonObject); // Output: {key: 'value'}
|
|
|
303
316
|
|
|
304
317
|
Converts the object to a JSON string.
|
|
305
318
|
|
|
306
|
-
-
|
|
319
|
+
- `target` : indicates the object to be converted.
|
|
307
320
|
|
|
308
321
|
```javascript
|
|
309
322
|
const obj = { key: "value" };
|
|
@@ -315,7 +328,7 @@ console.log(jsonString); // Output: '{"key":"value"}'
|
|
|
315
328
|
|
|
316
329
|
Check whether it is a browser window.
|
|
317
330
|
|
|
318
|
-
-
|
|
331
|
+
- `win` : indicates the object to be checked.
|
|
319
332
|
|
|
320
333
|
```javascript
|
|
321
334
|
const isBrowserWindow = isWindow(window);
|
|
@@ -326,7 +339,7 @@ console.log(isBrowserWindow); // Output: true
|
|
|
326
339
|
|
|
327
340
|
Creates an object whose prototype is empty.
|
|
328
341
|
|
|
329
|
-
-
|
|
342
|
+
- `init` : initializes the object.
|
|
330
343
|
|
|
331
344
|
```javascript
|
|
332
345
|
const o = emptyObject({ name: "hunter" });
|
|
@@ -340,7 +353,7 @@ console.log(o.__proto__, o2.__proto__); // Output: undefined, [Object: null prot
|
|
|
340
353
|
|
|
341
354
|
Randomly sort the array.
|
|
342
355
|
|
|
343
|
-
-
|
|
356
|
+
- `arr` : array to sort.
|
|
344
357
|
|
|
345
358
|
```javascript
|
|
346
359
|
const originalArray = [1, 2, 3, 4, 5];
|
|
@@ -353,7 +366,7 @@ console.log(randomizedArray);
|
|
|
353
366
|
|
|
354
367
|
Removes duplicate elements from the array.
|
|
355
368
|
|
|
356
|
-
-
|
|
369
|
+
- `arr` : array to process.
|
|
357
370
|
|
|
358
371
|
```javascript
|
|
359
372
|
const arrayWithDuplicates = [1, 2, 2, 3, 4, 4, 5];
|
|
@@ -366,8 +379,8 @@ console.log(uniqueArray);
|
|
|
366
379
|
|
|
367
380
|
Reduces the dimension of multiple nested arrays.
|
|
368
381
|
|
|
369
|
-
-
|
|
370
|
-
-
|
|
382
|
+
- `arr` : array to be reduced.
|
|
383
|
+
- `result` : The array used to store the result. The default is an empty array.
|
|
371
384
|
|
|
372
385
|
```javascript
|
|
373
386
|
const nestedArray = [1, [2, [3, [4]], 5]];
|
|
@@ -382,8 +395,8 @@ console.log(demotedArray);
|
|
|
382
395
|
|
|
383
396
|
Limits how often a function is called within a specified period of time.
|
|
384
397
|
|
|
385
|
-
-
|
|
386
|
-
-
|
|
398
|
+
- `fn` : function to be executed.
|
|
399
|
+
- `time` : indicates the time interval (milliseconds).
|
|
387
400
|
|
|
388
401
|
```javascript
|
|
389
402
|
const throttledFunction = throttle(
|
|
@@ -397,8 +410,8 @@ throttledFunction(); // This command is executed only after 1 second
|
|
|
397
410
|
|
|
398
411
|
Limits the continuous invocation of a function for a specified period of time.
|
|
399
412
|
|
|
400
|
-
-
|
|
401
|
-
-
|
|
413
|
+
- `fn` : function to be executed.
|
|
414
|
+
- `time` : indicates the time interval (milliseconds).
|
|
402
415
|
|
|
403
416
|
```javascript
|
|
404
417
|
const debouncedFunction = debounce(
|
|
@@ -412,7 +425,7 @@ debouncedFunction(); // Called multiple times within 1 second, only the last tim
|
|
|
412
425
|
|
|
413
426
|
Create a flat Promise delay object that can be set to time out after a certain amount of time.
|
|
414
427
|
|
|
415
|
-
-
|
|
428
|
+
- `timer` : indicates the timeout period (milliseconds). The default value is 0.
|
|
416
429
|
|
|
417
430
|
```javascript
|
|
418
431
|
const deferFn = () => {
|
|
@@ -432,7 +445,7 @@ delayFn().catch(console.error); // Timeout output
|
|
|
432
445
|
|
|
433
446
|
Catches an Error for an asynchronous operation and returns' [Error, null] 'or' [null, result] '.
|
|
434
447
|
|
|
435
|
-
-
|
|
448
|
+
- `defer` : The Promise object for the asynchronous operation.
|
|
436
449
|
|
|
437
450
|
```javascript
|
|
438
451
|
const asyncOperation = new Promise((resolve, reject) => {
|
|
@@ -471,10 +484,10 @@ clear(); // Cancel the execution
|
|
|
471
484
|
|
|
472
485
|
Creates and returns an HTML element.
|
|
473
486
|
|
|
474
|
-
-
|
|
475
|
-
-
|
|
476
|
-
-
|
|
477
|
-
-
|
|
487
|
+
- `ele` : element type or existing HTMLElement object, optional, default is 'div'.
|
|
488
|
+
- `style` : The style object of the element, optional.
|
|
489
|
+
- `attr` : attribute object of the element, optional.
|
|
490
|
+
- `parent` : indicates the parent of the element. This parameter is optional.
|
|
478
491
|
|
|
479
492
|
```javascript
|
|
480
493
|
const options = {
|
|
@@ -494,9 +507,9 @@ const createdElement = createElement(options);
|
|
|
494
507
|
|
|
495
508
|
Add event listeners to the element.
|
|
496
509
|
|
|
497
|
-
-
|
|
498
|
-
-
|
|
499
|
-
-
|
|
510
|
+
- `ele` : target element.
|
|
511
|
+
- `type` : indicates the type of the event.
|
|
512
|
+
- `handler` : event handler.
|
|
500
513
|
|
|
501
514
|
```javascript
|
|
502
515
|
const button = document.getElementById("myButton");
|
|
@@ -508,7 +521,7 @@ addHandler(button, "click", handleClick);
|
|
|
508
521
|
|
|
509
522
|
Prevent events from bubbling.
|
|
510
523
|
|
|
511
|
-
-
|
|
524
|
+
- `event` : indicates an event object.
|
|
512
525
|
|
|
513
526
|
```javascript
|
|
514
527
|
const handleClick = (event) => {
|
|
@@ -521,7 +534,7 @@ const handleClick = (event) => {
|
|
|
521
534
|
|
|
522
535
|
Default behavior to block events.
|
|
523
536
|
|
|
524
|
-
-
|
|
537
|
+
- `event` : indicates an event object.
|
|
525
538
|
|
|
526
539
|
```javascript
|
|
527
540
|
const handleFormSubmit = (event) => {
|
|
@@ -534,9 +547,9 @@ const handleFormSubmit = (event) => {
|
|
|
534
547
|
|
|
535
548
|
Removes an element's event listener.
|
|
536
549
|
|
|
537
|
-
-
|
|
538
|
-
-
|
|
539
|
-
-
|
|
550
|
+
- `ele` : target element.
|
|
551
|
+
- `type` : indicates the type of the event.
|
|
552
|
+
- `handler` : event handler to be removed.
|
|
540
553
|
|
|
541
554
|
```javascript
|
|
542
555
|
const button = document.getElementById("myButton");
|
|
@@ -550,8 +563,8 @@ removeHandler(button, "click", handleClick);
|
|
|
550
563
|
|
|
551
564
|
Trigger a custom event.
|
|
552
565
|
|
|
553
|
-
-
|
|
554
|
-
-
|
|
566
|
+
- `ele` : target element.
|
|
567
|
+
- `data` : indicates the data of a custom event.
|
|
555
568
|
|
|
556
569
|
```javascript
|
|
557
570
|
const customEvent = new CustomEvent("customEvent", {
|
|
@@ -567,8 +580,8 @@ dispatchEvent(targetElement, customEvent);
|
|
|
567
580
|
|
|
568
581
|
Store values to local storage.
|
|
569
582
|
|
|
570
|
-
-
|
|
571
|
-
-
|
|
583
|
+
- `key` : specifies the name of the key.
|
|
584
|
+
- `val` : The value to be stored.
|
|
572
585
|
|
|
573
586
|
```javascript
|
|
574
587
|
const userData = { username: "john_doe", email: "john@example.com" };
|
|
@@ -579,7 +592,7 @@ setStorage("user_data", userData);
|
|
|
579
592
|
|
|
580
593
|
Gets the value from local storage.
|
|
581
594
|
|
|
582
|
-
-
|
|
595
|
+
- `key` : specifies the key name to be obtained.
|
|
583
596
|
|
|
584
597
|
```javascript
|
|
585
598
|
const storedUserData = getStorage("user_data");
|
|
@@ -591,7 +604,7 @@ console.log(storedUserData);
|
|
|
591
604
|
|
|
592
605
|
Clear the value from the local store.
|
|
593
606
|
|
|
594
|
-
-
|
|
607
|
+
- `key` : specifies the name of the key to be cleared. If no key name is provided, all storage is cleared.
|
|
595
608
|
|
|
596
609
|
```javascript
|
|
597
610
|
clearStorage("user_data"); // Clear the stored value for a specific key name
|
|
@@ -605,9 +618,9 @@ clearStorage(); // Clear all locally stored values
|
|
|
605
618
|
|
|
606
619
|
Output logs in one line.
|
|
607
620
|
|
|
608
|
-
-
|
|
609
|
-
-
|
|
610
|
-
-
|
|
621
|
+
- `str` : The string to be output.
|
|
622
|
+
- `overwrite` : Whether to overwrite the current line. The default is' false '.
|
|
623
|
+
- `wrap` : Whether to wrap lines after output, defaults to 'true'.
|
|
611
624
|
|
|
612
625
|
```javascript
|
|
613
626
|
logOneLine("This is a single line log message.");
|
|
@@ -617,11 +630,11 @@ logOneLine("This is a single line log message.");
|
|
|
617
630
|
|
|
618
631
|
Output a loop animation in the console.
|
|
619
632
|
|
|
620
|
-
-
|
|
633
|
+
- `opts` : an optional parameter object containing the following properties:
|
|
621
634
|
- `loopList` : animation character list, the default is `[' \ \ ', '|', '/', '-', '-']`.
|
|
622
|
-
-
|
|
623
|
-
-
|
|
624
|
-
-
|
|
635
|
+
- `isStop` : Whether to stop the loop. The default is' false '.
|
|
636
|
+
- `timer` : Animation switch interval (milliseconds), default is' 100 '.
|
|
637
|
+
- `index` : indicates the index of the current animated character. The default value is 0.
|
|
625
638
|
|
|
626
639
|
```javascript
|
|
627
640
|
logLoop(); // Start the default loop animation
|
|
@@ -636,7 +649,7 @@ logLoop({ loopList: ["-", "+", "-", "+"], timer: 200 }); // Start a custom loop
|
|
|
636
649
|
A class that provides frame animation.
|
|
637
650
|
|
|
638
651
|
- `start(duration? : number): void ': Starts frame animation, optional parameter' duration 'is frame number control.
|
|
639
|
-
-
|
|
652
|
+
- `stop(): void` : stops frame animation.
|
|
640
653
|
|
|
641
654
|
```javascript
|
|
642
655
|
const animateFrame = new AnimateFrame((timestamp) => {
|
|
@@ -653,9 +666,9 @@ animateFrame.stop(); // Stop frame animation
|
|
|
653
666
|
|
|
654
667
|
Calculate the coordinates of points on the quadratic Bessel curve.
|
|
655
668
|
|
|
656
|
-
-
|
|
657
|
-
-
|
|
658
|
-
-
|
|
669
|
+
- `\_x` : x coordinates of control point 1.
|
|
670
|
+
- `\_y` : y coordinate of control point 1.
|
|
671
|
+
- `t` : indicates the time parameter. The value ranges from 0 to 1.
|
|
659
672
|
|
|
660
673
|
```javascript
|
|
661
674
|
const result = quadraticBezier(0, 0, 1, 1, 0.5);
|
|
@@ -667,11 +680,11 @@ console.log(result);
|
|
|
667
680
|
|
|
668
681
|
Calculate the coordinates of points on a cubic Bezier curve.
|
|
669
682
|
|
|
670
|
-
-
|
|
671
|
-
-
|
|
672
|
-
-
|
|
673
|
-
-
|
|
674
|
-
-
|
|
683
|
+
- `\_x1` : x coordinate of control point 1.
|
|
684
|
+
- `\_y1` : y coordinate of control point 1.
|
|
685
|
+
- `\_x2` : control point 2 x coordinates.
|
|
686
|
+
- `\_y2` : y coordinate of control point 2.
|
|
687
|
+
- `t` : indicates the time parameter. The value ranges from 0 to 1.
|
|
675
688
|
|
|
676
689
|
```javascript
|
|
677
690
|
const result = cubicBezier(0, 0, 0.5, 1, 0.5);
|
|
@@ -696,7 +709,7 @@ console.log(result);
|
|
|
696
709
|
Calculate the number of combinations.
|
|
697
710
|
|
|
698
711
|
- n: indicates the total number.
|
|
699
|
-
-
|
|
712
|
+
- `k` : indicates the number of selected items.
|
|
700
713
|
|
|
701
714
|
```javascript
|
|
702
715
|
const result = combination(5, 2);
|
|
@@ -708,8 +721,8 @@ console.log(result);
|
|
|
708
721
|
|
|
709
722
|
Calculate the point coordinates on the NTH Bezier curve.
|
|
710
723
|
|
|
711
|
-
-
|
|
712
|
-
-
|
|
724
|
+
- `points` : array of control points. Each point is a second-order array.
|
|
725
|
+
- `t` : indicates the time parameter. The value ranges from 0 to 1.
|
|
713
726
|
|
|
714
727
|
```javascript
|
|
715
728
|
const points = [
|
package/README.md
CHANGED
|
@@ -124,6 +124,19 @@ const isTypeAllowed = getTypeByList(data, allowedTypes);
|
|
|
124
124
|
console.log(isTypeAllowed); // 输出: true
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
+
##### 6. `toKebabCase(camelCase: string, separator: string = "-"): string`
|
|
128
|
+
|
|
129
|
+
驼峰式命名转换为连字符式命名
|
|
130
|
+
|
|
131
|
+
- `camelCase`: 驼峰式变量
|
|
132
|
+
- `separator`: 分隔符
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
const camelCase = 'fontSize';
|
|
136
|
+
const kebabCase = toKebabCase(camelCase);
|
|
137
|
+
console.log(kebabCase); // 输出: font-size
|
|
138
|
+
```
|
|
139
|
+
|
|
127
140
|
#### object 模块
|
|
128
141
|
|
|
129
142
|
##### 1. `getValue(object: object, key: string, defaultValue: any = ''): any`
|
package/dist/bundle/base.d.ts
CHANGED
|
@@ -5,11 +5,13 @@ export declare const urlSplit: IUrlSplit;
|
|
|
5
5
|
export declare const urlJoin: IUrlJoin;
|
|
6
6
|
export declare const getType: IGetType<types>;
|
|
7
7
|
export declare const getTypeByList: IGetTypeByList;
|
|
8
|
+
export declare const toKebabCase: (camelCase: string, separator?: string) => string;
|
|
8
9
|
declare const _default: {
|
|
9
10
|
randomNum: IRandomNum;
|
|
10
11
|
urlSplit: IUrlSplit;
|
|
11
12
|
urlJoin: IUrlJoin;
|
|
12
13
|
getType: IGetType<types>;
|
|
13
14
|
getTypeByList: IGetTypeByList;
|
|
15
|
+
toKebabCase: (camelCase: string, separator?: string) => string;
|
|
14
16
|
};
|
|
15
17
|
export default _default;
|
package/dist/bundle/index.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ declare const _default: {
|
|
|
52
52
|
urlJoin: import("./types").IUrlJoin;
|
|
53
53
|
getType: import("./types").IGetType<import("./static").types>;
|
|
54
54
|
getTypeByList: import("./types").IGetTypeByList;
|
|
55
|
+
toKebabCase: (camelCase: string, separator?: string) => string;
|
|
55
56
|
getValue: import("./types").IGetValue;
|
|
56
57
|
setValue: import("./types").ISetValue;
|
|
57
58
|
mixIn: import("./types").IMixIn;
|