@idlebox/common 1.3.6 → 1.3.7

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.
Files changed (80) hide show
  1. package/lib/string/concatType.generated.cjs +1 -1
  2. package/lib/string/concatType.generated.cjs.map +1 -1
  3. package/lib/string/concatType.generated.js +1 -1
  4. package/lib/string/concatType.generated.js.map +1 -1
  5. package/package.json +1 -1
  6. package/.rush/temp/8ffc60c66c29712a4b0392d78f8ceb08fd99cd43.log +0 -10
  7. package/.rush/temp/shrinkwrap-deps.json +0 -671
  8. package/Gulpfile.js +0 -4
  9. package/build-script.json +0 -55
  10. package/common.build.log +0 -42
  11. package/config/rush-project.json +0 -4
  12. package/docs/common.api.json +0 -21006
  13. package/docs/common.api.md +0 -1125
  14. package/docs/tsdoc-metadata.json +0 -11
  15. package/idlebox-common-v1.3.2.tgz +0 -0
  16. package/idlebox-common-v1.3.3.tgz +0 -0
  17. package/src/array/arrayDiff.ts +0 -31
  18. package/src/array/arraySame.ts +0 -15
  19. package/src/array/arrayUnique.ts +0 -50
  20. package/src/array/normalizeArray.ts +0 -13
  21. package/src/array/sortAlpha.ts +0 -15
  22. package/src/date/consts.ts +0 -5
  23. package/src/date/isInvalid.ts +0 -6
  24. package/src/date/sibling.ts +0 -28
  25. package/src/date/timeString.ts +0 -150
  26. package/src/date/unix.ts +0 -13
  27. package/src/debugging/tryInspect.ts +0 -37
  28. package/src/error/convertUnknown.ts +0 -10
  29. package/src/error/getFrame.ts +0 -13
  30. package/src/function/asyncCallbackList.ts +0 -75
  31. package/src/function/callbackList.ts +0 -84
  32. package/src/function/delayCallbackList.ts +0 -45
  33. package/src/function/functionName.ts +0 -39
  34. package/src/lifecycle/dispose/bridges/rxjs.ts +0 -6
  35. package/src/lifecycle/dispose/disposableEvent.ts +0 -117
  36. package/src/lifecycle/dispose/disposedError.ts +0 -16
  37. package/src/lifecycle/dispose/lifecycle.async.ts +0 -61
  38. package/src/lifecycle/dispose/lifecycle.global.ts +0 -61
  39. package/src/lifecycle/dispose/lifecycle.sync.ts +0 -79
  40. package/src/lifecycle/dispose/lifecycle.ts +0 -28
  41. package/src/lifecycle/event/event.ts +0 -63
  42. package/src/lifecycle/promise/cancel.ts +0 -16
  43. package/src/lifecycle/promise/cancellationToken/driver.browser.ts +0 -55
  44. package/src/lifecycle/promise/cancellationToken/driver.common.ts +0 -43
  45. package/src/lifecycle/promise/cancellationToken/source.ts +0 -48
  46. package/src/lifecycle/promise/deferredPromise.ts +0 -102
  47. package/src/lifecycle/timeout/timeout.ts +0 -48
  48. package/src/lifecycle/timeout/timeoutError.ts +0 -16
  49. package/src/log/logger.ts +0 -148
  50. package/src/mapSet/customSet.ts +0 -91
  51. package/src/mapSet/extendMap.ts +0 -40
  52. package/src/misc/assertNotNull.ts +0 -21
  53. package/src/object/definePublicConstant.ts +0 -10
  54. package/src/object/initOnRead.ts +0 -27
  55. package/src/object/objectPath.ts +0 -10
  56. package/src/object/objectSame.ts +0 -52
  57. package/src/path/isAbsolute.ts +0 -11
  58. package/src/path/normalizePath.ts +0 -8
  59. package/src/path/pathArray.ts +0 -42
  60. package/src/platform/globalObject.ts +0 -18
  61. package/src/platform/globalSingleton.ts +0 -82
  62. package/src/platform/globalSymbol.ts +0 -36
  63. package/src/platform/os.ts +0 -45
  64. package/src/promise/awaitIterator.ts +0 -19
  65. package/src/promise/finishAllPromise.ts +0 -50
  66. package/src/promise/promiseBool.ts +0 -10
  67. package/src/promise/promisePool.ts +0 -40
  68. package/src/promise/timeoutPromisePool.ts +0 -22
  69. package/src/reflection/classes/hookClass.ts +0 -47
  70. package/src/reflection/classes/singleton.ts +0 -33
  71. package/src/reflection/methods/bind.ts +0 -30
  72. package/src/reflection/methods/initOnRead.ts +0 -11
  73. package/src/reflection/methods/memorize.ts +0 -33
  74. package/src/string/castCase.ts +0 -44
  75. package/src/string/concatType.generated.ts +0 -255
  76. package/src/string/concatType.generator.ts +0 -31
  77. package/src/string/escapeRegexp.ts +0 -4
  78. package/src/string/pad2.ts +0 -11
  79. package/src/string/sizeString.ts +0 -52
  80. package/src/tsconfig.json +0 -13
@@ -1,45 +0,0 @@
1
- declare const process: any;
2
- declare const navigator: any;
3
-
4
- let _isWindows = false;
5
- let _isMacintosh = false;
6
- let _isLinux = false;
7
- let _isNative = false;
8
- let _isWeb = false;
9
- let _userAgent: string;
10
-
11
- export const isElectron =
12
- typeof process !== 'undefined' &&
13
- typeof process.versions !== 'undefined' &&
14
- typeof process.versions.electron !== 'undefined';
15
- export const isElectronRenderer = isElectron && process.type === 'renderer';
16
- export const isElectronMain = !isElectronRenderer;
17
-
18
- if (typeof navigator === 'object' && !isElectronRenderer) {
19
- _userAgent = navigator.userAgent;
20
- _isWindows = _userAgent.indexOf('Windows') >= 0;
21
- _isMacintosh = _userAgent.indexOf('Macintosh') >= 0;
22
- _isLinux = _userAgent.indexOf('Linux') >= 0;
23
- _isWeb = true;
24
- } else if (typeof process === 'object') {
25
- _userAgent = `nodejs(${process.versions.node})`;
26
- if (process.versions.electron) {
27
- _userAgent += ` electron(${process.versions.electron})`;
28
- if (isElectronRenderer) {
29
- _userAgent += ' ' + navigator.userAgent;
30
- }
31
- }
32
- _isWindows = process.platform === 'win32';
33
- _isMacintosh = process.platform === 'darwin';
34
- _isLinux = process.platform === 'linux';
35
- _isNative = true;
36
- } else {
37
- _userAgent = 'unsupported';
38
- }
39
-
40
- export const isWindows = _isWindows;
41
- export const isMacintosh = _isMacintosh;
42
- export const isLinux = _isLinux;
43
- export const isNative = _isNative;
44
- export const isWeb = _isWeb;
45
- export const userAgent = _userAgent;
@@ -1,19 +0,0 @@
1
- /**
2
- * Convert Iterator into Promise, resolve with the last value from Iterator
3
- */
4
- export async function awaitIterator<T>(generator: Iterator<T>): Promise<T> {
5
- let lastValue: any = {};
6
- do {
7
- const itr: IteratorResult<any> = generator.next(lastValue);
8
- if (itr.done) {
9
- return itr.value || lastValue;
10
- }
11
- if (itr.value[Symbol.iterator]) {
12
- lastValue = await awaitIterator(<any>itr.value);
13
- } else if (itr.value.then) {
14
- lastValue = await itr.value;
15
- } else {
16
- lastValue = itr.value;
17
- }
18
- } while (true);
19
- }
@@ -1,50 +0,0 @@
1
- /** @deprecated */
2
- export interface PromiseResultArray<T> {
3
- count: number;
4
- fulfilledResult: T[];
5
- fulfilled: number[];
6
- rejectedResult: Error[];
7
- rejected: number[];
8
- }
9
-
10
- /**
11
- * @deprecated Use Promise.allSettled instead
12
- */
13
- export function finishAllPromise<T>(ps: Promise<T>[]) {
14
- return new Promise<PromiseResultArray<T>>((resolve) => {
15
- const fulfilledResult: T[] = [];
16
- const rejectedResult: Error[] = [];
17
- const fulfilled: number[] = [];
18
- const rejected: number[] = [];
19
- let last = ps.length;
20
-
21
- const toDone = () => {
22
- if (last === 0) {
23
- resolve({
24
- count: ps.length,
25
- fulfilledResult,
26
- fulfilled,
27
- rejectedResult,
28
- rejected,
29
- });
30
- }
31
- };
32
-
33
- ps.forEach((p, index) => {
34
- p.then(
35
- (t) => {
36
- fulfilledResult[index] = t;
37
- fulfilled.push(index);
38
- last--;
39
- toDone();
40
- },
41
- (e) => {
42
- rejectedResult[index] = e;
43
- rejected.push(index);
44
- last--;
45
- toDone();
46
- }
47
- );
48
- });
49
- });
50
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * resolve with true when `p` resolve
3
- * resolve with false when `p` reject (and drop error)
4
- */
5
- export function promiseBool(p: Promise<any>): Promise<boolean> {
6
- return p.then(
7
- () => true,
8
- () => false
9
- );
10
- }
@@ -1,40 +0,0 @@
1
- import { CanceledError } from '../lifecycle/promise/cancel';
2
- import { DeferredPromise } from '../lifecycle/promise/deferredPromise';
3
-
4
- export class PromisePool {
5
- protected readonly promiseList: Record<string, DeferredPromise<any>> = {};
6
-
7
- size() {
8
- return Object.keys(this.promiseList).length;
9
- }
10
-
11
- create(id: string) {
12
- if (this.promiseList[id]) {
13
- throw new Error('duplicate promise with id ' + id);
14
- }
15
- const dfd = new DeferredPromise<any>();
16
- this.promiseList[id] = dfd;
17
- return dfd.p;
18
- }
19
-
20
- has(id: string) {
21
- return this.promiseList.hasOwnProperty(id);
22
- }
23
-
24
- done(id: string, data: any) {
25
- this.promiseList[id].complete(data);
26
- delete this.promiseList[id];
27
- }
28
-
29
- error(id: string, e: Error) {
30
- this.promiseList[id].error(e);
31
- delete this.promiseList[id];
32
- }
33
-
34
- dispose() {
35
- const e = new CanceledError();
36
- for (const id of Object.keys(this.promiseList)) {
37
- this.error(id, e);
38
- }
39
- }
40
- }
@@ -1,22 +0,0 @@
1
- import { TimeoutError } from '../lifecycle/timeout/timeoutError';
2
- import { PromisePool } from './promisePool';
3
-
4
- export class TimeoutPromisePool extends PromisePool {
5
- constructor(private readonly defaultTimeoutMs = 50000) {
6
- super();
7
- }
8
-
9
- create(id: string, timeoutMs: number = this.defaultTimeoutMs, timeoutMsg?: string) {
10
- const p = super.create(id);
11
-
12
- const to = setTimeout(() => {
13
- this.error(id, new TimeoutError(timeoutMs, timeoutMsg));
14
- }, timeoutMs);
15
-
16
- p.finally(() => {
17
- clearTimeout(to);
18
- });
19
-
20
- return p;
21
- }
22
- }
@@ -1,47 +0,0 @@
1
- export const hookClassSymbol = Symbol('@gongt/hookClass');
2
-
3
- interface IConstructorOf<T> extends Object {
4
- new (...args: any[]): T;
5
- }
6
-
7
- interface IHooks<T, TC> {
8
- afterConstruct?: ((obj: T) => void)[];
9
- beforeConstruct?: ((obj: TC) => T | void)[];
10
- }
11
-
12
- export function hookClass<TC extends IConstructorOf<T>, T>(target: TC): IHooks<T, TC> {
13
- if ((target as any)[hookClassSymbol]) {
14
- return (target as any)[hookClassSymbol];
15
- }
16
-
17
- const hooks = {} as IHooks<T, TC>;
18
-
19
- const proxyTarget = new Proxy(target, {
20
- construct(target: any, argArray: any): object {
21
- if (hooks.beforeConstruct) {
22
- for (const beforeCb of hooks.beforeConstruct) {
23
- const ret = beforeCb(target);
24
- if (ret) {
25
- return ret as any;
26
- }
27
- }
28
- }
29
- const d = new target(...argArray);
30
- if (hooks.afterConstruct) {
31
- for (const afterCb of hooks.afterConstruct) {
32
- afterCb(d);
33
- }
34
- }
35
- return d;
36
- },
37
- });
38
-
39
- Object.defineProperty(proxyTarget, hookClassSymbol, {
40
- value: hooks,
41
- enumerable: false,
42
- configurable: false,
43
- writable: false,
44
- });
45
-
46
- return hooks;
47
- }
@@ -1,33 +0,0 @@
1
- import { hookClass } from './hookClass';
2
-
3
- export const singletonSymbol = Symbol('@gongt/singleton');
4
-
5
- export enum SingletonType {
6
- Throw,
7
- Return,
8
- }
9
-
10
- export function singleton(type: SingletonType = SingletonType.Return): ClassDecorator {
11
- return (target: any): any => {
12
- const hook = hookClass(target);
13
- if (!hook.beforeConstruct) {
14
- hook.beforeConstruct = [];
15
- }
16
- if (!hook.afterConstruct) {
17
- hook.afterConstruct = [];
18
- }
19
-
20
- hook.beforeConstruct.push((cls) => {
21
- if (cls[singletonSymbol]) {
22
- if (type === SingletonType.Return) {
23
- return cls[singletonSymbol];
24
- } else {
25
- throw new Error(`Duplicate new singleton class [${target.name}]`);
26
- }
27
- }
28
- });
29
- hook.afterConstruct.push((obj) => {
30
- target[singletonSymbol] = obj;
31
- });
32
- };
33
- }
@@ -1,30 +0,0 @@
1
- /**
2
- * Auto bind `this` to class method
3
- */
4
- export const bindThis: MethodDecorator = <T>(
5
- _target: Object,
6
- propertyKey: string | symbol,
7
- descriptor: TypedPropertyDescriptor<T>
8
- ) => {
9
- const oldFunc = descriptor.value;
10
- if (typeof oldFunc === 'function') {
11
- return {
12
- enumerable: true,
13
- configurable: true,
14
- get: function (this: any) {
15
- delete this[propertyKey];
16
-
17
- const fn = oldFunc.bind(this);
18
- Object.defineProperty(this, propertyKey, {
19
- value: fn,
20
- writable: false,
21
- enumerable: true,
22
- configurable: false,
23
- });
24
- return fn;
25
- },
26
- };
27
- } else {
28
- throw new TypeError('@bindThis can only use with method, but not property.');
29
- }
30
- };
@@ -1,11 +0,0 @@
1
- import { InitFunc, initOnRead } from '../../object/initOnRead';
2
-
3
- /**
4
- * Decorater version of `initOnRead`
5
- * @see initOnRead
6
- */
7
- export function init<O, T extends keyof O>(init: InitFunc<O, O[T]>): PropertyDecorator {
8
- return function (target: O, propertyKey: T) {
9
- initOnRead<O, T>(target, propertyKey, init);
10
- } as any;
11
- }
@@ -1,33 +0,0 @@
1
- export const memorizeValueSymbol = Symbol('@gongt/memorizeValue');
2
-
3
- /**
4
- * Decorate class method/getter
5
- *
6
- * remember first return value of method/getter, directlly return memorized value when call it again
7
- */
8
- export const memo: MethodDecorator = <T>(
9
- _target: Object,
10
- propertyKey: string | symbol,
11
- descriptor: TypedPropertyDescriptor<T>
12
- ) => {
13
- const original: Function = (descriptor.value ? descriptor.value : descriptor.get) as any;
14
- if (descriptor.set || typeof original !== 'function') {
15
- throw new TypeError('@memo should only use on method, or getter. Not property and setter.');
16
- }
17
-
18
- if (descriptor.get) {
19
- descriptor.get = function memo_getter(this: any) {
20
- const value = original.call(this, arguments);
21
- Object.defineProperty(this, propertyKey, { value });
22
- return value;
23
- };
24
- } else {
25
- descriptor.value = function memo_method(this: any) {
26
- const value = original.call(this, arguments);
27
- Object.defineProperty(this, propertyKey, { value: () => value });
28
- return value;
29
- } as any;
30
- }
31
-
32
- return descriptor;
33
- };
@@ -1,44 +0,0 @@
1
- /** @public */
2
- export function camelCase(str: string) {
3
- return str.replace(/[-.\/_][a-z]/g, (s) => {
4
- return s[1].toUpperCase();
5
- });
6
- }
7
-
8
- /**
9
- * Uppercase first char
10
- * @public
11
- */
12
- export function ucfirst<T extends string>(str: T): Capitalize<T> {
13
- return <any>(str[0].toUpperCase() + str.slice(1));
14
- }
15
-
16
- /**
17
- * lowercase first char
18
- * @public
19
- */
20
- export function lcfirst<T extends string>(str: T): Uncapitalize<T> {
21
- return <any>(str[0].toLowerCase() + str.slice(1));
22
- }
23
-
24
- /** @public */
25
- export function linux_case(str: string) {
26
- return str
27
- .replace(/^[A-Z]/, (s) => {
28
- return s.toLowerCase();
29
- })
30
- .replace(/[A-Z]/g, (s) => {
31
- return '_' + s.toLowerCase();
32
- });
33
- }
34
-
35
- /** @public */
36
- export function linux_case_hyphen(str: string) {
37
- return str
38
- .replace(/^[A-Z]/, (s) => {
39
- return s.toLowerCase();
40
- })
41
- .replace(/[A-Z]/g, (s) => {
42
- return '-' + s.toLowerCase();
43
- });
44
- }
@@ -1,255 +0,0 @@
1
- export function concatStringType<T0 extends string>(
2
- t0: T0
3
- ): `${T0}`;
4
- export function concatStringType<T0 extends string, T1 extends string>(
5
- t0: T0,
6
- t1: T1
7
- ): `${T0}${T1}`;
8
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string>(
9
- t0: T0,
10
- t1: T1,
11
- t2: T2
12
- ): `${T0}${T1}${T2}`;
13
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string>(
14
- t0: T0,
15
- t1: T1,
16
- t2: T2,
17
- t3: T3
18
- ): `${T0}${T1}${T2}${T3}`;
19
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string>(
20
- t0: T0,
21
- t1: T1,
22
- t2: T2,
23
- t3: T3,
24
- t4: T4
25
- ): `${T0}${T1}${T2}${T3}${T4}`;
26
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string>(
27
- t0: T0,
28
- t1: T1,
29
- t2: T2,
30
- t3: T3,
31
- t4: T4,
32
- t5: T5
33
- ): `${T0}${T1}${T2}${T3}${T4}${T5}`;
34
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string>(
35
- t0: T0,
36
- t1: T1,
37
- t2: T2,
38
- t3: T3,
39
- t4: T4,
40
- t5: T5,
41
- t6: T6
42
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}`;
43
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string>(
44
- t0: T0,
45
- t1: T1,
46
- t2: T2,
47
- t3: T3,
48
- t4: T4,
49
- t5: T5,
50
- t6: T6,
51
- t7: T7
52
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}`;
53
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string>(
54
- t0: T0,
55
- t1: T1,
56
- t2: T2,
57
- t3: T3,
58
- t4: T4,
59
- t5: T5,
60
- t6: T6,
61
- t7: T7,
62
- t8: T8
63
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}`;
64
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string>(
65
- t0: T0,
66
- t1: T1,
67
- t2: T2,
68
- t3: T3,
69
- t4: T4,
70
- t5: T5,
71
- t6: T6,
72
- t7: T7,
73
- t8: T8,
74
- t9: T9
75
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}`;
76
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string>(
77
- t0: T0,
78
- t1: T1,
79
- t2: T2,
80
- t3: T3,
81
- t4: T4,
82
- t5: T5,
83
- t6: T6,
84
- t7: T7,
85
- t8: T8,
86
- t9: T9,
87
- t10: T10
88
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}`;
89
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string>(
90
- t0: T0,
91
- t1: T1,
92
- t2: T2,
93
- t3: T3,
94
- t4: T4,
95
- t5: T5,
96
- t6: T6,
97
- t7: T7,
98
- t8: T8,
99
- t9: T9,
100
- t10: T10,
101
- t11: T11
102
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}`;
103
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string>(
104
- t0: T0,
105
- t1: T1,
106
- t2: T2,
107
- t3: T3,
108
- t4: T4,
109
- t5: T5,
110
- t6: T6,
111
- t7: T7,
112
- t8: T8,
113
- t9: T9,
114
- t10: T10,
115
- t11: T11,
116
- t12: T12
117
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}`;
118
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string>(
119
- t0: T0,
120
- t1: T1,
121
- t2: T2,
122
- t3: T3,
123
- t4: T4,
124
- t5: T5,
125
- t6: T6,
126
- t7: T7,
127
- t8: T8,
128
- t9: T9,
129
- t10: T10,
130
- t11: T11,
131
- t12: T12,
132
- t13: T13
133
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}`;
134
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string>(
135
- t0: T0,
136
- t1: T1,
137
- t2: T2,
138
- t3: T3,
139
- t4: T4,
140
- t5: T5,
141
- t6: T6,
142
- t7: T7,
143
- t8: T8,
144
- t9: T9,
145
- t10: T10,
146
- t11: T11,
147
- t12: T12,
148
- t13: T13,
149
- t14: T14
150
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}`;
151
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string, T15 extends string>(
152
- t0: T0,
153
- t1: T1,
154
- t2: T2,
155
- t3: T3,
156
- t4: T4,
157
- t5: T5,
158
- t6: T6,
159
- t7: T7,
160
- t8: T8,
161
- t9: T9,
162
- t10: T10,
163
- t11: T11,
164
- t12: T12,
165
- t13: T13,
166
- t14: T14,
167
- t15: T15
168
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}`;
169
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string, T15 extends string, T16 extends string>(
170
- t0: T0,
171
- t1: T1,
172
- t2: T2,
173
- t3: T3,
174
- t4: T4,
175
- t5: T5,
176
- t6: T6,
177
- t7: T7,
178
- t8: T8,
179
- t9: T9,
180
- t10: T10,
181
- t11: T11,
182
- t12: T12,
183
- t13: T13,
184
- t14: T14,
185
- t15: T15,
186
- t16: T16
187
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}`;
188
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string, T15 extends string, T16 extends string, T17 extends string>(
189
- t0: T0,
190
- t1: T1,
191
- t2: T2,
192
- t3: T3,
193
- t4: T4,
194
- t5: T5,
195
- t6: T6,
196
- t7: T7,
197
- t8: T8,
198
- t9: T9,
199
- t10: T10,
200
- t11: T11,
201
- t12: T12,
202
- t13: T13,
203
- t14: T14,
204
- t15: T15,
205
- t16: T16,
206
- t17: T17
207
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}${T17}`;
208
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string, T15 extends string, T16 extends string, T17 extends string, T18 extends string>(
209
- t0: T0,
210
- t1: T1,
211
- t2: T2,
212
- t3: T3,
213
- t4: T4,
214
- t5: T5,
215
- t6: T6,
216
- t7: T7,
217
- t8: T8,
218
- t9: T9,
219
- t10: T10,
220
- t11: T11,
221
- t12: T12,
222
- t13: T13,
223
- t14: T14,
224
- t15: T15,
225
- t16: T16,
226
- t17: T17,
227
- t18: T18
228
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}${T17}${T18}`;
229
- export function concatStringType<T0 extends string, T1 extends string, T2 extends string, T3 extends string, T4 extends string, T5 extends string, T6 extends string, T7 extends string, T8 extends string, T9 extends string, T10 extends string, T11 extends string, T12 extends string, T13 extends string, T14 extends string, T15 extends string, T16 extends string, T17 extends string, T18 extends string, T19 extends string>(
230
- t0: T0,
231
- t1: T1,
232
- t2: T2,
233
- t3: T3,
234
- t4: T4,
235
- t5: T5,
236
- t6: T6,
237
- t7: T7,
238
- t8: T8,
239
- t9: T9,
240
- t10: T10,
241
- t11: T11,
242
- t12: T12,
243
- t13: T13,
244
- t14: T14,
245
- t15: T15,
246
- t16: T16,
247
- t17: T17,
248
- t18: T18,
249
- t19: T19
250
- ): `${T0}${T1}${T2}${T3}${T4}${T5}${T6}${T7}${T8}${T9}${T10}${T11}${T12}${T13}${T14}${T15}${T16}${T17}${T18}${T19}`;
251
-
252
- /* copy */
253
- export function concatStringType(a: string[]): string {
254
- return a.join('');
255
- }
@@ -1,31 +0,0 @@
1
- import { readFileSync } from 'fs';
2
-
3
- /* copy */
4
- export function concatStringType(a: string[]): string {
5
- return a.join('');
6
- }
7
- /* copy end */
8
-
9
- export function generate() {
10
- let content = '';
11
- const typeList = [];
12
- const argList = [];
13
- const returnList = [];
14
- for (let i = 0; i < 20; i++) {
15
- typeList.push(`T${i} extends string`);
16
- argList.push(`t${i}: T${i}`);
17
- returnList.push(`\${T${i}}`);
18
-
19
- const type = typeList.join(', ');
20
- const arg = argList.join(',\n\t');
21
- const ret = returnList.join('');
22
- content += `export function concatStringType<${type}>(\n\t${arg}\n): \`${ret}\`;\n`;
23
- }
24
-
25
- const full: string = readFileSync(import.meta.url.replace(/^file:\/\//, ''), 'utf-8');
26
- const lines = full.split('\n');
27
- content += '\n';
28
- content += lines.slice(lines.indexOf('/* copy */'), lines.indexOf('/* copy end */')).join('\n');
29
-
30
- return content;
31
- }
@@ -1,4 +0,0 @@
1
- /** @public */
2
- export function escapeRegExp(str: string) {
3
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
4
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Pad number to two digits string, used in time format
3
- * @public
4
- */
5
- export function pad2(s: number) {
6
- if (s < 10) {
7
- return '0' + s;
8
- } else {
9
- return '' + s;
10
- }
11
- }