mazey 3.3.11 → 3.3.12

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/lib/index.d.ts CHANGED
@@ -3,8 +3,16 @@
3
3
  *
4
4
  * ZH: 计算两个字符串的最长公共子串
5
5
  *
6
+ * Usage:
7
+ *
8
+ * ```
9
+ * calLongestCommonSubstring('fish', 'finish');
10
+ * ```
11
+ *
12
+ * Output:
13
+ *
6
14
  * ```
7
- * calLongestCommonSubstring('fish', 'finish'); // 3
15
+ * 3
8
16
  * ```
9
17
  *
10
18
  * @param {string} aStr String
@@ -17,8 +25,16 @@ export declare function calLongestCommonSubstring(aStr: string, bStr: string): n
17
25
  *
18
26
  * ZH: 计算两个字符串的最长公共子序列
19
27
  *
28
+ * Usage:
29
+ *
30
+ * ```
31
+ * calLongestCommonSubsequence('fish', 'finish');
32
+ * ```
33
+ *
34
+ * Output:
35
+ *
20
36
  * ```
21
- * calLongestCommonSubsequence('fish', 'finish'); // 4
37
+ * 4
22
38
  * ```
23
39
  *
24
40
  * @param {string} aStr 字符串
@@ -27,23 +43,49 @@ export declare function calLongestCommonSubstring(aStr: string, bStr: string): n
27
43
  */
28
44
  export declare function calLongestCommonSubsequence(aStr: string, bStr: string): number;
29
45
  /**
30
- * @method getQueryParam
31
- * @description Get the query param's value of the current Web URL(`location.search`).
46
+ * Get the query param's value of the current Web URL(`location.search`).
47
+ *
48
+ * ```
49
+ * // http://example.com/?t1=1&t2=2&t3=3&t4=4#2333
50
+ * // ?t1=1&t2=2&t3=3&t4=4
51
+ * getQueryParam('t3'); // 3
52
+ * getQueryParam('t4'); // 4
53
+ * ```
54
+ *
32
55
  * @param {string} param Query param.
33
56
  * @returns {string} value
34
57
  */
35
58
  export declare function getQueryParam(param: string): string;
36
59
  /**
37
- * @method getUrlParam
38
- * @description Get the query param's value of the input URL.
60
+ * Get the query param's value of the input URL.
61
+ *
62
+ * ```
63
+ * getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3'); // 3
64
+ * getUrlParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4'); // 4
65
+ * ```
66
+ *
39
67
  * @param {string} url URL string.
40
68
  * @param {string} param Query param.
41
69
  * @returns {string} value
42
70
  */
43
71
  export declare function getUrlParam(url: string, param: string): string | string[];
44
72
  /**
45
- * @method updateQueryParam
46
- * @description Update the query param's value of the input URL.
73
+ * Update the query param's value of the input URL.
74
+ *
75
+ * Usage:
76
+ *
77
+ * ```
78
+ * updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't3', 'three');
79
+ * updateQueryParam('http://example.com/?t1=1&t2=2&t3=3&t4=4', 't4', 'four');
80
+ * ```
81
+ *
82
+ * Output:
83
+ *
84
+ * ```
85
+ * http://example.com/?t1=1&t2=2&t3=three&t4=4
86
+ * http://example.com/?t1=1&t2=2&t3=3&t4=four
87
+ * ```
88
+ *
47
89
  * @param {string} url URL string.
48
90
  * @param {string} param Query param.
49
91
  * @param {string} value Param's value.
@@ -51,36 +93,81 @@ export declare function getUrlParam(url: string, param: string): string | string
51
93
  */
52
94
  export declare function updateQueryParam(url: string, param: string, value: string): string;
53
95
  /**
54
- * @method getHashQueryParam
55
- * @description Get the hash query param's value of the current Web URL(`location.hash`).
96
+ * Get the hash query param's value of the current Web URL(`location.hash`).
97
+ *
98
+ * Usage:
99
+ *
100
+ * ```
101
+ * // http://example.com/?#2333?t1=1&t2=2&t3=3&t4=4
102
+ * // #2333?t1=1&t2=2&t3=3&t4=4
103
+ * getHashQueryParam('t3');
104
+ * getHashQueryParam('t4');
105
+ * ```
106
+ *
107
+ * Output:
108
+ *
109
+ * ```
110
+ * 3
111
+ * 4
112
+ * ```
113
+ *
56
114
  * @param {string} param Query param.
57
115
  * @returns {string} value
58
116
  */
59
117
  export declare function getHashQueryParam(param: string): string;
60
118
  /**
61
- * @method getDomain
62
- * @description Get the domain of URL, and other params.
119
+ * Get the domain of URL, and other params.
120
+ *
121
+ * Usage:
122
+ *
123
+ * ```
124
+ * getDomain('http://example.com/?t1=1&t2=2&t3=3&t4=4');
125
+ * getDomain('http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4', ['hostname', 'pathname']);
126
+ * ```
127
+ *
128
+ * Output:
129
+ *
130
+ * ```
131
+ * example.com
132
+ * example.com/test/thanks
133
+ * ```
134
+ *
63
135
  * @param {string} url
64
136
  * @param {array} rules Object.keys(location), ['href', 'protocol', 'host', 'hostname', 'port', 'pathname', 'search', 'hash'], ['hostname', 'pathname'] = 'km.mazey.net/plugins/servlet/mobile'
65
137
  */
66
138
  export declare function getDomain(url: string, rules?: string[]): string;
67
139
  /**
68
- * @method camelCaseToKebabCase
69
- * @description Transfer CamelCase to KebabCase.
140
+ * Transfer CamelCase to KebabCase.
141
+ *
142
+ * ```
143
+ * camelCaseToKebabCase('ABC'); // a-b-c
144
+ * camelCaseToKebabCase('aBC'); // a-b-c
145
+ * ```
146
+ *
70
147
  * @param {string} camelCase 'aBC' or 'ABC'
71
148
  * @returns {string} 'a-b-c'
72
149
  */
73
150
  export declare function camelCaseToKebabCase(camelCase: string): string;
74
151
  /**
75
- * @method camelCase2Underscore
76
- * @description Transfer CamelCase to Underscore.
152
+ * Transfer CamelCase to Underscore.
153
+ *
154
+ * ```
155
+ * camelCase2Underscore('ABC'); // a_b_c
156
+ * camelCase2Underscore('aBC'); // a_b_c
157
+ * ```
158
+ *
77
159
  * @param {string} camelCase 'aBC' or 'ABC'
78
160
  * @returns {string} 'a_b_c'
79
161
  */
80
162
  export declare function camelCase2Underscore(camelCase: string): string;
81
163
  /**
82
- * @method mTrim
83
- * @description Remove leading and trailing whitespace or specified characters from string.
164
+ * Remove leading and trailing whitespace or specified characters from string.
165
+ *
166
+ * ```
167
+ * mTrim(' 1 2 3 '); // '1 2 3'
168
+ * mTrim('abc '); // 'abc'
169
+ * ```
170
+ *
84
171
  * @param {string} str The string to trim.
85
172
  * @returns {string} Trimmed string.
86
173
  */
@@ -93,17 +180,42 @@ export declare function mTrim(str: string): string;
93
180
  */
94
181
  export declare function newLine(str: string): string;
95
182
  /**
96
- * @method deepCopyObject
97
- * @description Clone Object deeply.
183
+ * Clone Object deeply.
184
+ *
185
+ * Usage:
186
+ *
187
+ * ```
188
+ * deepCopyObject(['a', 'b', 'c']);
189
+ * deepCopyObject('abc');
190
+ * ```
191
+ *
192
+ * Output:
193
+ *
194
+ * ```
195
+ * ['a', 'b', 'c']
196
+ * 'abc'
197
+ * ```
198
+ *
98
199
  * @param {object} obj The value to clone.
99
200
  * @returns {object} Returns the deep cloned value.
100
201
  */
101
202
  export declare function deepCopyObject(obj: any): any;
102
203
  /**
103
- * @method isJsonString
104
- * @description Check whether it is a valid JSON string.
105
- * @param {string} str The string to check.
106
- * @returns {boolean} Return the result of checking.
204
+ * Check whether it is a valid JSON string.
205
+ *
206
+ * Usage:
207
+ *
208
+ * ```
209
+ * isJsonString(`['a', 'b', 'c']`);
210
+ * isJsonString(`["a", "b", "c"]`);
211
+ * ```
212
+ *
213
+ * Output:
214
+ *
215
+ * ```
216
+ * false
217
+ * true
218
+ * ```
107
219
  */
108
220
  export declare function isJsonString(str: string): boolean;
109
221
  /**
@@ -153,6 +265,12 @@ export declare function removeClass(obj: any, cls: string): void;
153
265
  *
154
266
  * ZH: 节流
155
267
  *
268
+ * ```
269
+ * const foo = throttle(() => {
270
+ * console.log('The function will be invoked at most once per every wait 1000 milliseconds.');
271
+ * }, 1000, { leading: true });
272
+ * ```
273
+ *
156
274
  * Reference: [Lodash](https://lodash.com/docs/4.17.15#throttle)
157
275
  */
158
276
  export declare function throttle(func: any, wait: number, options?: {
@@ -164,8 +282,6 @@ export declare function throttle(func: any, wait: number, options?: {
164
282
  *
165
283
  * ZH: 去抖
166
284
  *
167
- * Usage:
168
- *
169
285
  * ```
170
286
  * const foo = debounce(() => {
171
287
  * console.log('The debounced function will only be invoked in 1000 milliseconds, the other invoking will disappear during the wait time.');
@@ -185,8 +301,20 @@ export declare function friendlyInterval(start?: number, end?: number, options?:
185
301
  type?: string;
186
302
  }): number | string;
187
303
  /**
188
- * @method isNumber
189
- * @description 判断是否有效数字
304
+ * EN: Check whether it is a right number.
305
+ *
306
+ * ZH: 判断是否有效数字
307
+ *
308
+ * ```
309
+ * isNumber(123); // true
310
+ * isNumber('123'); // false
311
+ * // Default: NaN, Infinity is not Number
312
+ * isNumber(Infinity); // false
313
+ * isNumber(Infinity, { isUnFiniteAsNumber: true }); // true
314
+ * isNumber(NaN); // false
315
+ * isNumber(NaN, { isNaNAsNumber: true, isUnFiniteAsNumber: true }); // true
316
+ * ```
317
+ *
190
318
  * @param {*} num 被判断的值
191
319
  * @param {boolean} options.isNaNAsNumber 是否 NaN 算数字(默认不算)
192
320
  * @param {boolean} options.isUnFiniteAsNumber 是否 无限 算数字(默认不算)
@@ -231,8 +359,29 @@ export declare function setLocalStorage(key: string, value?: any): void;
231
359
  */
232
360
  export declare function getLocalStorage(key: string): any;
233
361
  /**
234
- * @method loadCSS
235
- * @description 动态加载css文件
362
+ * EN: Load a CSS file from the server.
363
+ *
364
+ * ZH: 动态加载 CSS 文件
365
+ *
366
+ * ```
367
+ * loadCSS(
368
+ * 'http://example.com/css/mazey-base.css',
369
+ * {
370
+ * id: 'iamid', // Optional, link ID, default none
371
+ * }
372
+ * )
373
+ * .then(
374
+ * res => {
375
+ * console.log(`Load CSS Success: ${res}`);
376
+ * }
377
+ * )
378
+ * .catch(
379
+ * err => {
380
+ * console.error(`Load CSS Fail: ${err.message}`)
381
+ * }
382
+ * );
383
+ * ```
384
+ *
236
385
  * @param {string} url -- css资源路径
237
386
  * @param {string} options.id -- link标签id
238
387
  * @returns {Promise<boolean>} true -- 加载成功
@@ -241,9 +390,32 @@ export declare function loadCSS(url: string, options?: {
241
390
  id?: string;
242
391
  }): Promise<boolean | Error | any>;
243
392
  /**
244
- * @method loadScript
245
- * @description 动态加载js文件
246
- * @param {string} url -- js资源路径
393
+ * EN: Load a JavaScript file from the server and execute it.
394
+ *
395
+ * ZH: 动态加载 JavaScript 文件
396
+ *
397
+ * ```
398
+ * loadScript(
399
+ * 'http://example.com/static/js/plugin-2.1.1.min.js',
400
+ * {
401
+ * id: 'iamid', // (Optional) script ID, default none
402
+ * timeout: 5000, // (Optional) timeout, default `5000`
403
+ * isDefer: false, // (Optional) defer, default `false`
404
+ * }
405
+ * )
406
+ * .then(
407
+ * res => {
408
+ * console.log(`Load JavaScript script: ${res}`);
409
+ * }
410
+ * )
411
+ * .catch(
412
+ * err => {
413
+ * console.error(`Load JavaScript script: ${err.message}`)
414
+ * }
415
+ * );
416
+ * ```
417
+ *
418
+ * @param {string} url -- JavaScript 资源路径
247
419
  * @param {string} options.id -- DOM ID
248
420
  * @param {function} options.callback -- 加载后回调函数
249
421
  * @param {number} options.timeout -- 超时时长
@@ -275,22 +447,102 @@ interface WebPerformance {
275
447
  [key: string]: string | number;
276
448
  }
277
449
  /**
278
- * @method getPerformance
279
- * @description 获取页面加载相关的各项数据
450
+ * EN: Get page load time(PerformanceTiming).
451
+ *
452
+ * ZH: 获取页面加载相关的各项数据
453
+ *
454
+ * Usage:
455
+ *
456
+ * ```
457
+ * // `camelCase:true`(Default) Return hump data.
458
+ * // `camelCase:false` Return underline data.
459
+ * getPerformance(true)
460
+ * .then(res => {
461
+ * console.log(JSON.stringify(res));
462
+ * })
463
+ * .catch(console.error);
464
+ * ```
465
+ *
466
+ * Output:
467
+ *
468
+ * ```
469
+ * {"deviceType":"pc","network":"3g","unloadTime":0,"redirectTime":0,"dnsTime":0,"tcpTime":0,"responseTime":65,"downloadTime":1,"domreadyTime":369,"onloadTime":441,"whiteTime":94,"renderTime":441,"decodedBodySize":210,"encodedBodySize":210}
470
+ * ```
471
+ *
472
+ * Results:
473
+ *
474
+ * | Index | Field | Description |
475
+ * | --- | --- | --- |
476
+ * | DNS lookup | dns_time | domainLookupEnd - domainLookupStart |
477
+ * | Connection negotiation | tcp_time | connectEnd - connectStart |
478
+ * | Requests and responses | response_time | responseStart - requestStart |
479
+ * | White screen | white_time | responseStart - navigationStart |
480
+ * | DomReady | domready_time | domContentLoadedEventStart - navigationStart |
481
+ * | Onload | onload_time | loadEventStart - navigationStart |
482
+ * | EventEnd | render_time | loadEventEnd -navigationStart |
483
+ * | Unload | unload_time | (Optional) unloadEventEnd - unloadEventStart |
484
+ * | Redirect | redirect_time | (Optional) redirectEnd - redirectStart |
485
+ * | SSL | ssl_time | (Optional) connectEnd - secureConnectionStart |
486
+ * | Download | download_time | (Optional) responseEnd - responseStart |
487
+ *
280
488
  * @param {boolean} camelCase -- true(默认) 以驼峰形式返回数据 false 以下划线形式返回数据
281
489
  * @returns {Promise<object>} 加载数据
282
490
  */
283
491
  export declare function getPerformance(camelCase?: boolean): Promise<WebPerformance | Error>;
284
492
  /**
285
- * @method inRate
286
- * @description 百分位概率
493
+ * EN: Hit probability (1% ~ 100%).
494
+ *
495
+ * ZH: 百分位概率
496
+ *
497
+ * Usage:
498
+ *
499
+ * ```
500
+ * inRate(0.5); // 0.01 ~ 1 true/false
501
+ * ```
502
+ *
503
+ * Output:
504
+ *
505
+ * ```
506
+ * true
507
+ * ```
508
+ *
509
+ * Example: Test the precision.
510
+ *
511
+ * ```
512
+ * // Test
513
+ * let trueCount = 0;
514
+ * let falseCount = 0;
515
+ * new Array(1000000).fill(0).forEach(() => {
516
+ * if (inRate(0.5)) {
517
+ * trueCount++;
518
+ * } else {
519
+ * falseCount++;
520
+ * }
521
+ * });
522
+ * console.log(trueCount, falseCount); // 499994 500006
523
+ * ```
524
+ *
287
525
  * @param {number} rate -- 0.1 ~ 1 => 1% ~ 100%
288
526
  * @returns {boolean} true 命中
289
527
  */
290
528
  export declare function inRate(rate: number): boolean;
291
529
  /**
292
- * @method isSafePWAEnv
293
- * @description 判断是否是安全的 PWA 环境
530
+ * EN: Determine if it is a secure PWA environment that it can run.
531
+ *
532
+ * ZH: 判断是否是安全的 PWA 环境
533
+ *
534
+ * Usage:
535
+ *
536
+ * ```
537
+ * isSafePWAEnv();
538
+ * ```
539
+ *
540
+ * Output:
541
+ *
542
+ * ```
543
+ * true
544
+ * ```
545
+ *
294
546
  * @returns {boolean} true 是
295
547
  */
296
548
  export declare function isSafePWAEnv(): boolean;
@@ -299,10 +551,20 @@ export declare function isSafePWAEnv(): boolean;
299
551
  *
300
552
  * ZH: 返回浏览器信息 https://github.com/JowayYoung/juejin-code/blob/master/browser-type.js
301
553
  *
554
+ * Usage:
555
+ *
556
+ * ```
557
+ * getBrowserInfo();
558
+ * ```
559
+ *
560
+ * Output:
561
+ *
302
562
  * ```
303
- * getBrowserInfo(); // {"engine":"webkit","engineVs":"537.36","platform":"desktop","supporter":"chrome","supporterVs":"85.0.4183.121","system":"windows","systemVs":"10"}
563
+ * {"engine":"webkit","engineVs":"537.36","platform":"desktop","supporter":"chrome","supporterVs":"85.0.4183.121","system":"windows","systemVs":"10"}
304
564
  * ```
305
565
  *
566
+ * Results:
567
+ *
306
568
  * | Index | Field | Description |
307
569
  * | --- | --- | --- |
308
570
  * | System | system | android, ios, windows, macos, linux |
@@ -313,7 +575,7 @@ export declare function isSafePWAEnv(): boolean;
313
575
  * | Supporter | supporter | edge, opera, chrome, safari, firefox, iexplore |
314
576
  * | Supporter version | supporterVs | - |
315
577
  * | Shell | shell | (Optional) wechat, qq_browser, qq_app, uc, 360, 2345, sougou, liebao, maxthon, bilibili |
316
- * | Shell version | shellVs | (Optional) |
578
+ * | Shell version | shellVs | (Optional) 20/... |
317
579
  * | Apple device type | appleType | (Optional) iphone, ipad, ipod, iwatch |
318
580
  *
319
581
  * Example: Determine the environment of the mobile QQ.
@@ -354,8 +616,20 @@ export declare function clearHtml(str: string): string;
354
616
  */
355
617
  export declare function cutCHSString(str: string, len: number, hasDot?: boolean): string;
356
618
  /**
357
- * @method windowLoaded
358
- * @description 页面加载完成
619
+ * EN: Check whether the page is loaded successfully (Keepe the compatibility in case that browser's `load` event has been triggered).
620
+ *
621
+ * ZH: 页面加载完成
622
+ *
623
+ * ```
624
+ * windowLoaded(30) // second
625
+ * .then(res => {
626
+ * console.log(`Load Success: ${res}`); // Load Success: load
627
+ * })
628
+ * .catch(err => {
629
+ * console.log(`Load Timeout or Fail: ${err.message}`);
630
+ * });
631
+ * ```
632
+ *
359
633
  * @param {number} timeout 超时时间 / 单位:秒
360
634
  * @returns {Promise<string>} document is loaded? 'complete' 'load' / 'timeout'
361
635
  */
@@ -410,7 +684,28 @@ export declare function addStyle(style: string, options?: {
410
684
  id?: string;
411
685
  }): boolean;
412
686
  /**
413
- * 生成自定义控制台打印
687
+ * EN: Custom console printing (`console`).
688
+ *
689
+ * ZH: 生成自定义控制台打印
690
+ *
691
+ * Usage:
692
+ *
693
+ * ```
694
+ * const myConsole = genCustomConsole('MazeyLog:');
695
+ * myConsole.log('I am string.');
696
+ * myConsole.info('I am boolean.', true);
697
+ * myConsole.info('I am number.', 123, 456);
698
+ * myConsole.info('I am object.', { a: 123, b: 456});
699
+ * ```
700
+ *
701
+ * Output:
702
+ *
703
+ * ```
704
+ * MazeyLog: I am string.
705
+ * MazeyLog: I am boolean. true
706
+ * MazeyLog: I am number. 123 456
707
+ * MazeyLog: I am object. {a: 123, b: 456}
708
+ * ```
414
709
  *
415
710
  * @param {string} prefix 前缀
416
711
  * @param {string} locales A locale string.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB5E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,MAAM,CA8BR;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQnD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MA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,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CAQtB,GACA,OAAO,CAoFT;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,EACR,OAAO,GAAE;IACP,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,SAAS,EAAE,MAAM,EAAE,CAAC;CAIrB,GACA,OAAO,CAyBT;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAMnD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiBhD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAAC,OAAO,CAAC,CAahD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU/C"}
package/lib/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * mazey v3.3.11
2
+ * mazey v3.3.12
3
3
  * (c) 2018-2022 Mazey Chu
4
4
  * Released under the MIT License.
5
5
  */
package/lib/mazey.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * mazey v3.3.11
2
+ * mazey v3.3.12
3
3
  * (c) 2018-2022 Mazey Chu
4
4
  * Released under the MIT License.
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mazey",
3
- "version": "3.3.11",
3
+ "version": "3.3.12",
4
4
  "description": "Mazey's library for front-end.",
5
5
  "main": "lib/index.cjs.js",
6
6
  "module": "lib/index.esm.js",
@@ -82,6 +82,7 @@
82
82
  "husky": "^4.3.8",
83
83
  "jest": "^27.5.1",
84
84
  "lint-staged": "^10.0.8",
85
+ "markdown-toc": "^1.2.0",
85
86
  "prettier": "^1.19.1",
86
87
  "prettier-eslint-cli": "^5.0.0",
87
88
  "rollup": "^2.79.1",
@@ -3,6 +3,8 @@
3
3
  const path = require('path');
4
4
  const _resolve = (_path) => path.resolve(__dirname, _path);
5
5
  const format = require('date-fns/format');
6
+ const toc = require('markdown-toc');
7
+ const fs = require('fs');
6
8
  // Generate version: 20210308.072903
7
9
  const genVersion = () => {
8
10
  const d = new Date();
@@ -11,7 +13,47 @@ const genVersion = () => {
11
13
  };
12
14
  const version = genVersion();
13
15
 
16
+ const generateToc = () => {
17
+ console.log('Generating Table of Contents...');
18
+ const RMFilePath = _resolve('../README.md');
19
+ // https://melvingeorge.me/blog/get-all-the-contents-from-file-as-string-nodejs
20
+ console.log('running...');
21
+ const buffer = fs.readFileSync(RMFilePath);
22
+ const fileContent = buffer.toString();
23
+ // https://github.com/jonschlinkert/markdown-toc
24
+ const removeUnnecessaryHeadings = (str) => {
25
+ return ![
26
+ 'mazey',
27
+ 'Install',
28
+ 'Usage',
29
+ 'Contributing',
30
+ 'License',
31
+ 'API Examples',
32
+ ].some(v => {
33
+ return str.includes(v);
34
+ });
35
+ };
36
+ let tocContent = toc(fileContent, {
37
+ filter: removeUnnecessaryHeadings,
38
+ bullets: ['-', '*'],
39
+ }).content;
40
+ tocContent = tocContent.replace(/[ ]{4}/gm, '');
41
+ tocContent = '<!-- toc - begin -->\n' + '- Generate with ❤️\n' + tocContent;
42
+ tocContent = tocContent + '\n<!-- toc - end -->';
43
+ // console.log(tocContent);
44
+ // Insert to file.
45
+ // https://stackoverflow.com/questions/14177087/replace-a-string-in-a-file-with-nodejs
46
+ let newFileContent = fileContent;
47
+ // https://stackoverflow.com/questions/1979884/how-to-use-javascript-regex-over-multiple-lines
48
+ newFileContent = newFileContent.replace(/<!-- toc - begin -->[\s\S]*<!-- toc - end -->/gm, tocContent);
49
+ // console.log(newFileContent);
50
+ console.log('running...');
51
+ fs.writeFileSync(RMFilePath, newFileContent);
52
+ console.log('Generating Table of Contents is done.');
53
+ };
54
+
14
55
  module.exports = {
15
56
  _resolve,
16
57
  version,
58
+ generateToc,
17
59
  };
package/scripts/dev.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable no-undef */
2
2
  /* eslint-disable @typescript-eslint/no-var-requires */
3
3
  // const execa = require('execa');
4
- const { getGitCurrentBranch } = require('./github-helper');
4
+ const { generateToc } = require('./build-helper');
5
5
 
6
6
  (async () => {
7
7
  // const { stdout: pushMsg = '' } = await execa('git', ['push'], { stdio: 'pipe' })
@@ -17,6 +17,7 @@ const { getGitCurrentBranch } = require('./github-helper');
17
17
  // await execa('git', ['push', '--set-upstream', 'origin', currentBranch]);
18
18
  // }
19
19
  // console.log('pushMsg:', pushMsg);
20
- const cb = await getGitCurrentBranch('fix returns value');
21
- console.log('bbb', cb);
20
+ // const cb = await getGitCurrentBranch('fix returns value');
21
+ // console.log('bbb', cb);
22
+ generateToc();
22
23
  })();