complete-common 1.0.0 → 1.0.1
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/LICENSE +1 -1
- package/README.md +3 -3
- package/dist/constants.d.cts +7 -0
- package/dist/constants.d.mts +7 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/functions/array.d.cts +83 -0
- package/dist/functions/array.d.mts +83 -0
- package/dist/functions/array.d.ts +83 -0
- package/dist/functions/array.d.ts.map +1 -0
- package/dist/functions/assert.d.cts +22 -0
- package/dist/functions/assert.d.mts +22 -0
- package/dist/functions/assert.d.ts +22 -0
- package/dist/functions/assert.d.ts.map +1 -0
- package/dist/functions/enums.d.cts +73 -0
- package/dist/functions/enums.d.mts +73 -0
- package/dist/functions/enums.d.ts +73 -0
- package/dist/functions/enums.d.ts.map +1 -0
- package/dist/functions/map.d.cts +52 -0
- package/dist/functions/map.d.mts +52 -0
- package/dist/functions/map.d.ts +52 -0
- package/dist/functions/map.d.ts.map +1 -0
- package/dist/functions/math.d.cts +13 -0
- package/dist/functions/math.d.mts +13 -0
- package/dist/functions/math.d.ts +13 -0
- package/dist/functions/math.d.ts.map +1 -0
- package/dist/functions/object.d.cts +14 -0
- package/dist/functions/object.d.mts +14 -0
- package/dist/functions/object.d.ts +14 -0
- package/dist/functions/object.d.ts.map +1 -0
- package/dist/functions/random.d.cts +23 -0
- package/dist/functions/random.d.mts +23 -0
- package/dist/functions/random.d.ts +23 -0
- package/dist/functions/random.d.ts.map +1 -0
- package/dist/functions/set.d.cts +61 -0
- package/dist/functions/set.d.mts +61 -0
- package/dist/functions/set.d.ts +61 -0
- package/dist/functions/set.d.ts.map +1 -0
- package/dist/functions/sort.d.cts +14 -0
- package/dist/functions/sort.d.mts +14 -0
- package/dist/functions/sort.d.ts +14 -0
- package/dist/functions/sort.d.ts.map +1 -0
- package/dist/functions/string.d.cts +122 -0
- package/dist/functions/string.d.mts +122 -0
- package/dist/functions/string.d.ts +122 -0
- package/dist/functions/string.d.ts.map +1 -0
- package/dist/functions/string.test.d.cts +2 -0
- package/dist/functions/string.test.d.mts +2 -0
- package/dist/functions/string.test.d.ts +2 -0
- package/dist/functions/string.test.d.ts.map +1 -0
- package/dist/functions/tuple.d.cts +27 -0
- package/dist/functions/tuple.d.mts +27 -0
- package/dist/functions/tuple.d.ts +27 -0
- package/dist/functions/tuple.d.ts.map +1 -0
- package/dist/functions/types.d.cts +13 -0
- package/dist/functions/types.d.mts +13 -0
- package/dist/functions/types.d.ts +13 -0
- package/dist/functions/types.d.ts.map +1 -0
- package/dist/functions/utils.d.cts +131 -0
- package/dist/functions/utils.d.mts +131 -0
- package/dist/functions/utils.d.ts +131 -0
- package/dist/functions/utils.d.ts.map +1 -0
- package/dist/functions/utils.test.d.cts +2 -0
- package/dist/functions/utils.test.d.mts +2 -0
- package/dist/functions/utils.test.d.ts +2 -0
- package/dist/functions/utils.test.d.ts.map +1 -0
- package/dist/index.cjs +66 -65
- package/dist/index.d.cts +29 -705
- package/dist/index.d.mts +29 -705
- package/dist/index.d.ts +29 -705
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +66 -65
- package/dist/types/AddSubtract.d.cts +23 -0
- package/dist/types/AddSubtract.d.mts +23 -0
- package/dist/types/AddSubtract.d.ts +23 -0
- package/dist/types/AddSubtract.d.ts.map +1 -0
- package/dist/types/CompositionTypeSatisfiesEnum.d.cts +35 -0
- package/dist/types/CompositionTypeSatisfiesEnum.d.mts +35 -0
- package/dist/types/CompositionTypeSatisfiesEnum.d.ts +35 -0
- package/dist/types/CompositionTypeSatisfiesEnum.d.ts.map +1 -0
- package/dist/types/ERange.d.cts +12 -0
- package/dist/types/ERange.d.mts +12 -0
- package/dist/types/ERange.d.ts +12 -0
- package/dist/types/ERange.d.ts.map +1 -0
- package/dist/types/IRange.d.cts +13 -0
- package/dist/types/IRange.d.mts +13 -0
- package/dist/types/IRange.d.ts +13 -0
- package/dist/types/IRange.d.ts.map +1 -0
- package/dist/types/Immutable.d.cts +17 -0
- package/dist/types/Immutable.d.mts +17 -0
- package/dist/types/Immutable.d.ts +17 -0
- package/dist/types/Immutable.d.ts.map +1 -0
- package/dist/types/NaturalNumbersLessThan.d.cts +8 -0
- package/dist/types/NaturalNumbersLessThan.d.mts +8 -0
- package/dist/types/NaturalNumbersLessThan.d.ts +8 -0
- package/dist/types/NaturalNumbersLessThan.d.ts.map +1 -0
- package/dist/types/NaturalNumbersLessThanOrEqualTo.d.cts +8 -0
- package/dist/types/NaturalNumbersLessThanOrEqualTo.d.mts +8 -0
- package/dist/types/NaturalNumbersLessThanOrEqualTo.d.ts +8 -0
- package/dist/types/NaturalNumbersLessThanOrEqualTo.d.ts.map +1 -0
- package/dist/types/ObjectValues.d.cts +3 -0
- package/dist/types/ObjectValues.d.mts +3 -0
- package/dist/types/ObjectValues.d.ts +3 -0
- package/dist/types/ObjectValues.d.ts.map +1 -0
- package/dist/types/ReadonlyMap.d.cts +9 -0
- package/dist/types/ReadonlyMap.d.mts +9 -0
- package/dist/types/ReadonlyMap.d.ts +9 -0
- package/dist/types/ReadonlyMap.d.ts.map +1 -0
- package/dist/types/ReadonlyRecord.d.cts +7 -0
- package/dist/types/ReadonlyRecord.d.mts +7 -0
- package/dist/types/ReadonlyRecord.d.ts +7 -0
- package/dist/types/ReadonlyRecord.d.ts.map +1 -0
- package/dist/types/ReadonlySet.d.cts +8 -0
- package/dist/types/ReadonlySet.d.mts +8 -0
- package/dist/types/ReadonlySet.d.ts +8 -0
- package/dist/types/ReadonlySet.d.ts.map +1 -0
- package/dist/types/Tuple.d.cts +10 -0
- package/dist/types/Tuple.d.mts +10 -0
- package/dist/types/Tuple.d.ts +10 -0
- package/dist/types/Tuple.d.ts.map +1 -0
- package/dist/types/WidenLiteral.d.cts +3 -0
- package/dist/types/WidenLiteral.d.mts +3 -0
- package/dist/types/WidenLiteral.d.ts +3 -0
- package/dist/types/WidenLiteral.d.ts.map +1 -0
- package/dist/types/Writeable.d.cts +9 -0
- package/dist/types/Writeable.d.mts +9 -0
- package/dist/types/Writeable.d.ts +9 -0
- package/dist/types/Writeable.d.ts.map +1 -0
- package/package.json +12 -2
- package/src/constants.ts +5 -0
- package/src/functions/array.ts +8 -2
- package/src/functions/assert.ts +41 -0
- package/src/functions/enums.ts +6 -0
- package/src/functions/map.ts +7 -0
- package/src/functions/math.ts +6 -0
- package/src/functions/object.ts +8 -3
- package/src/functions/random.ts +6 -0
- package/src/functions/set.ts +7 -0
- package/src/functions/sort.ts +6 -0
- package/src/functions/string.ts +25 -0
- package/src/functions/tuple.ts +6 -0
- package/src/functions/types.ts +6 -0
- package/src/functions/utils.test.ts +2 -8
- package/src/functions/utils.ts +7 -37
- package/src/index.ts +13 -12
- package/src/types/AddSubtract.ts +10 -2
- package/src/types/CompositionTypeSatisfiesEnum.ts +5 -3
- package/src/types/ObjectValues.ts +1 -0
- package/src/types/ReadonlyRecord.ts +5 -0
- package/src/types/Tuple.ts +1 -0
- package/src/types/WidenLiteral.ts +1 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with
|
|
3
|
+
* [maps](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map).
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to get the values in a `Map` that match an arbitrary condition. Similar to the
|
|
9
|
+
* `Array.map` method, but works for maps.
|
|
10
|
+
*
|
|
11
|
+
* This is efficient such that it avoids converting the map values into an array.
|
|
12
|
+
*
|
|
13
|
+
* If you want to perform a filter and a map at the same time on an array, use the `filterMap`
|
|
14
|
+
* helper function instead.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mapFilter<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): V[];
|
|
17
|
+
/**
|
|
18
|
+
* Helper function to find a value in a `Map`. Similar to the `Array.find` method, but works for
|
|
19
|
+
* maps.
|
|
20
|
+
*
|
|
21
|
+
* This is efficient such that it avoids converting the map values into an array.
|
|
22
|
+
*/
|
|
23
|
+
export declare function mapFind<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): V | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Helper function to convert an object to a map.
|
|
26
|
+
*
|
|
27
|
+
* This is useful when you need to construct a type safe object with the `satisfies` operator, but
|
|
28
|
+
* then later on you need to query it in a way where you expect the return value to be T or
|
|
29
|
+
* undefined. In this situation, by converting the object to a map, you can avoid unsafe type
|
|
30
|
+
* assertions.
|
|
31
|
+
*
|
|
32
|
+
* Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
33
|
+
* hood.
|
|
34
|
+
*
|
|
35
|
+
* Also see the `objectToReadonlyMap` function.
|
|
36
|
+
*/
|
|
37
|
+
export declare function objectToMap<K extends string | number | symbol, V>(object: Record<K, V>): Map<K, V>;
|
|
38
|
+
/**
|
|
39
|
+
* Helper function to convert an object to a read-only map.
|
|
40
|
+
*
|
|
41
|
+
* This is useful when you need to construct a type safe object with the `satisfies` operator, but
|
|
42
|
+
* then later on you need to query it in a way where you expect the return value to be T or
|
|
43
|
+
* undefined. In this situation, by converting the object to a map, you can avoid unsafe type
|
|
44
|
+
* assertions.
|
|
45
|
+
*
|
|
46
|
+
* Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
47
|
+
* hood.
|
|
48
|
+
*
|
|
49
|
+
* Also see the `objectToMap` function.
|
|
50
|
+
*/
|
|
51
|
+
export declare function objectToReadonlyMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
|
|
52
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with
|
|
3
|
+
* [maps](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map).
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to get the values in a `Map` that match an arbitrary condition. Similar to the
|
|
9
|
+
* `Array.map` method, but works for maps.
|
|
10
|
+
*
|
|
11
|
+
* This is efficient such that it avoids converting the map values into an array.
|
|
12
|
+
*
|
|
13
|
+
* If you want to perform a filter and a map at the same time on an array, use the `filterMap`
|
|
14
|
+
* helper function instead.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mapFilter<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): V[];
|
|
17
|
+
/**
|
|
18
|
+
* Helper function to find a value in a `Map`. Similar to the `Array.find` method, but works for
|
|
19
|
+
* maps.
|
|
20
|
+
*
|
|
21
|
+
* This is efficient such that it avoids converting the map values into an array.
|
|
22
|
+
*/
|
|
23
|
+
export declare function mapFind<K, V>(map: ReadonlyMap<K, V>, predicate: (value: V) => boolean): V | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Helper function to convert an object to a map.
|
|
26
|
+
*
|
|
27
|
+
* This is useful when you need to construct a type safe object with the `satisfies` operator, but
|
|
28
|
+
* then later on you need to query it in a way where you expect the return value to be T or
|
|
29
|
+
* undefined. In this situation, by converting the object to a map, you can avoid unsafe type
|
|
30
|
+
* assertions.
|
|
31
|
+
*
|
|
32
|
+
* Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
33
|
+
* hood.
|
|
34
|
+
*
|
|
35
|
+
* Also see the `objectToReadonlyMap` function.
|
|
36
|
+
*/
|
|
37
|
+
export declare function objectToMap<K extends string | number | symbol, V>(object: Record<K, V>): Map<K, V>;
|
|
38
|
+
/**
|
|
39
|
+
* Helper function to convert an object to a read-only map.
|
|
40
|
+
*
|
|
41
|
+
* This is useful when you need to construct a type safe object with the `satisfies` operator, but
|
|
42
|
+
* then later on you need to query it in a way where you expect the return value to be T or
|
|
43
|
+
* undefined. In this situation, by converting the object to a map, you can avoid unsafe type
|
|
44
|
+
* assertions.
|
|
45
|
+
*
|
|
46
|
+
* Note that the map values will be inserted in a random order, due to how `pairs` works under the
|
|
47
|
+
* hood.
|
|
48
|
+
*
|
|
49
|
+
* Also see the `objectToMap` function.
|
|
50
|
+
*/
|
|
51
|
+
export declare function objectToReadonlyMap<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlyMap<K, V>;
|
|
52
|
+
//# sourceMappingURL=map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/functions/map.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;GAQG;AAEH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAC5B,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAC/B,CAAC,EAAE,CAWL;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,GAAG,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAC/B,CAAC,GAAG,SAAS,CASf;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EAC/D,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAQX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACvE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAEnB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with math.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Helper function to normalize a number, ensuring that it is within a certain range.
|
|
8
|
+
*
|
|
9
|
+
* - If `num` is less than `min`, then it will be clamped to `min`.
|
|
10
|
+
* - If `num` is greater than `max`, then it will be clamped to `max`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function clamp(num: number, min: number, max: number): number;
|
|
13
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with math.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Helper function to normalize a number, ensuring that it is within a certain range.
|
|
8
|
+
*
|
|
9
|
+
* - If `num` is less than `min`, then it will be clamped to `min`.
|
|
10
|
+
* - If `num` is greater than `max`, then it will be clamped to `max`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function clamp(num: number, min: number, max: number): number;
|
|
13
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with math.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Helper function to normalize a number, ensuring that it is within a certain range.
|
|
8
|
+
*
|
|
9
|
+
* - If `num` is less than `min`, then it will be clamped to `min`.
|
|
10
|
+
* - If `num` is greater than `max`, then it will be clamped to `max`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function clamp(num: number, min: number, max: number): number;
|
|
13
|
+
//# sourceMappingURL=math.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../../src/functions/math.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEnE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with objects.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { ReadonlyRecord } from "../types/ReadonlyRecord.js";
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to get the values in an object that match an arbitrary condition. Similar to the
|
|
9
|
+
* `Array.map` method, but works for objects.
|
|
10
|
+
*
|
|
11
|
+
* This is efficient such that it avoids converting the object values into an array.
|
|
12
|
+
*/
|
|
13
|
+
export declare function objectFilter<K extends string | number | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): V[];
|
|
14
|
+
//# sourceMappingURL=object.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with objects.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { ReadonlyRecord } from "../types/ReadonlyRecord.js";
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to get the values in an object that match an arbitrary condition. Similar to the
|
|
9
|
+
* `Array.map` method, but works for objects.
|
|
10
|
+
*
|
|
11
|
+
* This is efficient such that it avoids converting the object values into an array.
|
|
12
|
+
*/
|
|
13
|
+
export declare function objectFilter<K extends string | number | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): V[];
|
|
14
|
+
//# sourceMappingURL=object.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with objects.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { ReadonlyRecord } from "../types/ReadonlyRecord.js";
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to get the values in an object that match an arbitrary condition. Similar to the
|
|
9
|
+
* `Array.map` method, but works for objects.
|
|
10
|
+
*
|
|
11
|
+
* This is efficient such that it avoids converting the object values into an array.
|
|
12
|
+
*/
|
|
13
|
+
export declare function objectFilter<K extends string | number | symbol, V>(object: ReadonlyRecord<K, V>, predicate: (value: V) => boolean): V[];
|
|
14
|
+
//# sourceMappingURL=object.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../src/functions/object.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;;;;GAKG;AAEH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EAChE,MAAM,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAC5B,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAC/B,CAAC,EAAE,CAaL"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with getting random values.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* This returns a random integer between min and max. It is inclusive on both ends.
|
|
8
|
+
*
|
|
9
|
+
* For example:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const oneTwoOrThree = getRandomInt(1, 3);
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param min The lower bound for the random number (inclusive).
|
|
16
|
+
* @param max The upper bound for the random number (inclusive).
|
|
17
|
+
* @param exceptions Optional. An array of elements that will be skipped over when getting the
|
|
18
|
+
* random integer. For example, a min of 1, a max of 4, and an exceptions array of
|
|
19
|
+
* `[2]` would cause the function to return either 1, 3, or 4. Default is an empty
|
|
20
|
+
* array.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getRandomInt(min: number, max: number, exceptions?: readonly number[]): number;
|
|
23
|
+
//# sourceMappingURL=random.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with getting random values.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* This returns a random integer between min and max. It is inclusive on both ends.
|
|
8
|
+
*
|
|
9
|
+
* For example:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const oneTwoOrThree = getRandomInt(1, 3);
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param min The lower bound for the random number (inclusive).
|
|
16
|
+
* @param max The upper bound for the random number (inclusive).
|
|
17
|
+
* @param exceptions Optional. An array of elements that will be skipped over when getting the
|
|
18
|
+
* random integer. For example, a min of 1, a max of 4, and an exceptions array of
|
|
19
|
+
* `[2]` would cause the function to return either 1, 3, or 4. Default is an empty
|
|
20
|
+
* array.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getRandomInt(min: number, max: number, exceptions?: readonly number[]): number;
|
|
23
|
+
//# sourceMappingURL=random.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with getting random values.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* This returns a random integer between min and max. It is inclusive on both ends.
|
|
8
|
+
*
|
|
9
|
+
* For example:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const oneTwoOrThree = getRandomInt(1, 3);
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param min The lower bound for the random number (inclusive).
|
|
16
|
+
* @param max The upper bound for the random number (inclusive).
|
|
17
|
+
* @param exceptions Optional. An array of elements that will be skipped over when getting the
|
|
18
|
+
* random integer. For example, a min of 1, a max of 4, and an exceptions array of
|
|
19
|
+
* `[2]` would cause the function to return either 1, 3, or 4. Default is an empty
|
|
20
|
+
* array.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getRandomInt(min: number, max: number, exceptions?: readonly number[]): number;
|
|
23
|
+
//# sourceMappingURL=random.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../src/functions/random.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,UAAU,GAAE,SAAS,MAAM,EAAO,GACjC,MAAM,CAoBR"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with
|
|
3
|
+
* [sets](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set).
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to add all of the values in one set to another set. The first set passed will be
|
|
9
|
+
* modified in place.
|
|
10
|
+
*
|
|
11
|
+
* This function is variadic, meaning that you can specify N sets to add to the first set.
|
|
12
|
+
*/
|
|
13
|
+
export declare function addSetsToSet<T>(mainSet: Set<T>, ...setsToAdd: ReadonlyArray<ReadonlySet<T>>): void;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to create a new set that is the composition of two or more sets.
|
|
16
|
+
*
|
|
17
|
+
* This function is variadic, meaning that you can specify N sets.
|
|
18
|
+
*/
|
|
19
|
+
export declare function combineSets<T>(...sets: ReadonlyArray<ReadonlySet<T>>): Set<T>;
|
|
20
|
+
/** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
|
|
21
|
+
export declare function copySet<T>(oldSet: ReadonlySet<T>): Set<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Helper function to convert the keys of an object to a read-only set.
|
|
24
|
+
*
|
|
25
|
+
* Also see the `objectKeysToSet` function.
|
|
26
|
+
*/
|
|
27
|
+
export declare function objectKeysToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<K>;
|
|
28
|
+
/**
|
|
29
|
+
* Helper function to convert the keys of an object to a set.
|
|
30
|
+
*
|
|
31
|
+
* Also see the `objectKeysToReadonlySet` function.
|
|
32
|
+
*/
|
|
33
|
+
export declare function objectKeysToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<K>;
|
|
34
|
+
/**
|
|
35
|
+
* Helper function to convert the values of an object to a read-only set.
|
|
36
|
+
*
|
|
37
|
+
* Also see the `objectValuesToSet` function.
|
|
38
|
+
*/
|
|
39
|
+
export declare function objectValuesToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<V>;
|
|
40
|
+
/**
|
|
41
|
+
* Helper function to convert the values of an object to a set.
|
|
42
|
+
*
|
|
43
|
+
* Also see the `objectValuesToReadonlySet` function.
|
|
44
|
+
*/
|
|
45
|
+
export declare function objectValuesToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<V>;
|
|
46
|
+
/**
|
|
47
|
+
* Helper function to add one or more elements to a set at once without having to repeatedly call
|
|
48
|
+
* the `Set.add` method.
|
|
49
|
+
*
|
|
50
|
+
* This function is variadic, meaning that you can pass as many things as you want to add.
|
|
51
|
+
*/
|
|
52
|
+
export declare function setAdd<T>(set: Set<T>, ...elements: readonly T[]): void;
|
|
53
|
+
/**
|
|
54
|
+
* Helper function to check for one or more elements in a set at once without having to repeatedly
|
|
55
|
+
* call the `Set.has` method.
|
|
56
|
+
*
|
|
57
|
+
* This function is variadic, meaning that you can pass as many things as you want to check for. It
|
|
58
|
+
* will return true if one or more elements are found.
|
|
59
|
+
*/
|
|
60
|
+
export declare function setHas<T>(set: ReadonlySet<T>, ...elements: readonly T[]): boolean;
|
|
61
|
+
//# sourceMappingURL=set.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with
|
|
3
|
+
* [sets](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set).
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to add all of the values in one set to another set. The first set passed will be
|
|
9
|
+
* modified in place.
|
|
10
|
+
*
|
|
11
|
+
* This function is variadic, meaning that you can specify N sets to add to the first set.
|
|
12
|
+
*/
|
|
13
|
+
export declare function addSetsToSet<T>(mainSet: Set<T>, ...setsToAdd: ReadonlyArray<ReadonlySet<T>>): void;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to create a new set that is the composition of two or more sets.
|
|
16
|
+
*
|
|
17
|
+
* This function is variadic, meaning that you can specify N sets.
|
|
18
|
+
*/
|
|
19
|
+
export declare function combineSets<T>(...sets: ReadonlyArray<ReadonlySet<T>>): Set<T>;
|
|
20
|
+
/** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
|
|
21
|
+
export declare function copySet<T>(oldSet: ReadonlySet<T>): Set<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Helper function to convert the keys of an object to a read-only set.
|
|
24
|
+
*
|
|
25
|
+
* Also see the `objectKeysToSet` function.
|
|
26
|
+
*/
|
|
27
|
+
export declare function objectKeysToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<K>;
|
|
28
|
+
/**
|
|
29
|
+
* Helper function to convert the keys of an object to a set.
|
|
30
|
+
*
|
|
31
|
+
* Also see the `objectKeysToReadonlySet` function.
|
|
32
|
+
*/
|
|
33
|
+
export declare function objectKeysToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<K>;
|
|
34
|
+
/**
|
|
35
|
+
* Helper function to convert the values of an object to a read-only set.
|
|
36
|
+
*
|
|
37
|
+
* Also see the `objectValuesToSet` function.
|
|
38
|
+
*/
|
|
39
|
+
export declare function objectValuesToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<V>;
|
|
40
|
+
/**
|
|
41
|
+
* Helper function to convert the values of an object to a set.
|
|
42
|
+
*
|
|
43
|
+
* Also see the `objectValuesToReadonlySet` function.
|
|
44
|
+
*/
|
|
45
|
+
export declare function objectValuesToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<V>;
|
|
46
|
+
/**
|
|
47
|
+
* Helper function to add one or more elements to a set at once without having to repeatedly call
|
|
48
|
+
* the `Set.add` method.
|
|
49
|
+
*
|
|
50
|
+
* This function is variadic, meaning that you can pass as many things as you want to add.
|
|
51
|
+
*/
|
|
52
|
+
export declare function setAdd<T>(set: Set<T>, ...elements: readonly T[]): void;
|
|
53
|
+
/**
|
|
54
|
+
* Helper function to check for one or more elements in a set at once without having to repeatedly
|
|
55
|
+
* call the `Set.has` method.
|
|
56
|
+
*
|
|
57
|
+
* This function is variadic, meaning that you can pass as many things as you want to check for. It
|
|
58
|
+
* will return true if one or more elements are found.
|
|
59
|
+
*/
|
|
60
|
+
export declare function setHas<T>(set: ReadonlySet<T>, ...elements: readonly T[]): boolean;
|
|
61
|
+
//# sourceMappingURL=set.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with
|
|
3
|
+
* [sets](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set).
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Helper function to add all of the values in one set to another set. The first set passed will be
|
|
9
|
+
* modified in place.
|
|
10
|
+
*
|
|
11
|
+
* This function is variadic, meaning that you can specify N sets to add to the first set.
|
|
12
|
+
*/
|
|
13
|
+
export declare function addSetsToSet<T>(mainSet: Set<T>, ...setsToAdd: ReadonlyArray<ReadonlySet<T>>): void;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to create a new set that is the composition of two or more sets.
|
|
16
|
+
*
|
|
17
|
+
* This function is variadic, meaning that you can specify N sets.
|
|
18
|
+
*/
|
|
19
|
+
export declare function combineSets<T>(...sets: ReadonlyArray<ReadonlySet<T>>): Set<T>;
|
|
20
|
+
/** Helper function to copy a set. (You can also use a Set constructor to accomplish this task.) */
|
|
21
|
+
export declare function copySet<T>(oldSet: ReadonlySet<T>): Set<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Helper function to convert the keys of an object to a read-only set.
|
|
24
|
+
*
|
|
25
|
+
* Also see the `objectKeysToSet` function.
|
|
26
|
+
*/
|
|
27
|
+
export declare function objectKeysToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<K>;
|
|
28
|
+
/**
|
|
29
|
+
* Helper function to convert the keys of an object to a set.
|
|
30
|
+
*
|
|
31
|
+
* Also see the `objectKeysToReadonlySet` function.
|
|
32
|
+
*/
|
|
33
|
+
export declare function objectKeysToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<K>;
|
|
34
|
+
/**
|
|
35
|
+
* Helper function to convert the values of an object to a read-only set.
|
|
36
|
+
*
|
|
37
|
+
* Also see the `objectValuesToSet` function.
|
|
38
|
+
*/
|
|
39
|
+
export declare function objectValuesToReadonlySet<K extends string | number | symbol, V>(object: Record<K, V>): ReadonlySet<V>;
|
|
40
|
+
/**
|
|
41
|
+
* Helper function to convert the values of an object to a set.
|
|
42
|
+
*
|
|
43
|
+
* Also see the `objectValuesToReadonlySet` function.
|
|
44
|
+
*/
|
|
45
|
+
export declare function objectValuesToSet<K extends string | number | symbol, V>(object: Record<K, V>): Set<V>;
|
|
46
|
+
/**
|
|
47
|
+
* Helper function to add one or more elements to a set at once without having to repeatedly call
|
|
48
|
+
* the `Set.add` method.
|
|
49
|
+
*
|
|
50
|
+
* This function is variadic, meaning that you can pass as many things as you want to add.
|
|
51
|
+
*/
|
|
52
|
+
export declare function setAdd<T>(set: Set<T>, ...elements: readonly T[]): void;
|
|
53
|
+
/**
|
|
54
|
+
* Helper function to check for one or more elements in a set at once without having to repeatedly
|
|
55
|
+
* call the `Set.has` method.
|
|
56
|
+
*
|
|
57
|
+
* This function is variadic, meaning that you can pass as many things as you want to check for. It
|
|
58
|
+
* will return true if one or more elements are found.
|
|
59
|
+
*/
|
|
60
|
+
export declare function setHas<T>(set: ReadonlySet<T>, ...elements: readonly T[]): boolean;
|
|
61
|
+
//# sourceMappingURL=set.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/functions/set.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAE5B,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EACf,GAAG,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAC1C,IAAI,CAMN;AAED;;;;GAIG;AAEH,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAS7E;AAED,mGAAmG;AAEnG,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAOzD;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EAC3E,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,WAAW,CAAC,CAAC,CAAC,CAEhB;AAED;;;;GAIG;AAEH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACnE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,GAAG,CAAC,CAAC,CAAC,CAQR;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,CAAC,EACD,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAEtC;AAED;;;;GAIG;AAEH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,EACrE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GACnB,GAAG,CAAC,CAAC,CAAC,CAQR;AAED;;;;;GAKG;AAEH,wBAAgB,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,EAAE,SAAS,CAAC,EAAE,GAAG,IAAI,CAItE;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EACnB,GAAG,QAAQ,EAAE,SAAS,CAAC,EAAE,GACxB,OAAO,CAET"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with sorting.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Helper function to perform a case insensitive sort. This will copy the provided array and return
|
|
8
|
+
* the sorted copy.
|
|
9
|
+
*
|
|
10
|
+
* From:
|
|
11
|
+
* https://stackoverflow.com/questions/8996963/how-to-perform-case-insensitive-sorting-array-of-string-in-javascript
|
|
12
|
+
*/
|
|
13
|
+
export declare function sortCaseInsensitive(array: readonly string[]): string[];
|
|
14
|
+
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with sorting.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Helper function to perform a case insensitive sort. This will copy the provided array and return
|
|
8
|
+
* the sorted copy.
|
|
9
|
+
*
|
|
10
|
+
* From:
|
|
11
|
+
* https://stackoverflow.com/questions/8996963/how-to-perform-case-insensitive-sorting-array-of-string-in-javascript
|
|
12
|
+
*/
|
|
13
|
+
export declare function sortCaseInsensitive(array: readonly string[]): string[];
|
|
14
|
+
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with sorting.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Helper function to perform a case insensitive sort. This will copy the provided array and return
|
|
8
|
+
* the sorted copy.
|
|
9
|
+
*
|
|
10
|
+
* From:
|
|
11
|
+
* https://stackoverflow.com/questions/8996963/how-to-perform-case-insensitive-sorting-array-of-string-in-javascript
|
|
12
|
+
*/
|
|
13
|
+
export declare function sortCaseInsensitive(array: readonly string[]): string[];
|
|
14
|
+
//# sourceMappingURL=sort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort.d.ts","sourceRoot":"","sources":["../../src/functions/sort.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAStE"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions that have to do with strings.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/** Helper function to capitalize the first letter of a string. */
|
|
7
|
+
export declare function capitalizeFirstLetter(string: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to replace all of the ampersands, less than signs, greater than signs, double
|
|
10
|
+
* quotes, and single quotes in a string with the escaped counterparts. For example, "<" will be
|
|
11
|
+
* replaced with "<".
|
|
12
|
+
*/
|
|
13
|
+
export declare function escapeHTMLCharacters(string: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Helper function to get the number of consecutive diacritics in a string.
|
|
16
|
+
*
|
|
17
|
+
* This is useful for sanitization purposes, since many subsequent diacritics can be a sign of a
|
|
18
|
+
* malicious string.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getNumConsecutiveDiacritics(string: string): number;
|
|
21
|
+
/** Helper function to check if a string has one or more diacritics in it. */
|
|
22
|
+
export declare function hasDiacritic(string: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Helper function to check if a string has one or more emoji in it.
|
|
25
|
+
*
|
|
26
|
+
* Under the hood, this uses the same regex check as the Zod library.
|
|
27
|
+
*/
|
|
28
|
+
export declare function hasEmoji(string: string): boolean;
|
|
29
|
+
/** From: https://stackoverflow.com/questions/1731190/check-if-a-string-has-white-space */
|
|
30
|
+
export declare function hasWhitespace(string: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* From:
|
|
33
|
+
* https://stackoverflow.com/questions/8334606/check-if-first-letter-of-word-is-a-capital-letter
|
|
34
|
+
*/
|
|
35
|
+
export declare function isFirstLetterCapitalized(string: string): boolean;
|
|
36
|
+
/** Kebab case is the naming style of using all lowercase and hyphens, like "foo-bar". */
|
|
37
|
+
export declare function isKebabCase(string: string): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Helper function to check if a given string is a valid Semantic Version.
|
|
40
|
+
*
|
|
41
|
+
* @see https://semver.org/
|
|
42
|
+
*/
|
|
43
|
+
export declare function isSemanticVersion(versionString: string): boolean;
|
|
44
|
+
/** Helper function to convert a string from kebab-case to camel-case. */
|
|
45
|
+
export declare function kebabCaseToCamelCase(string: string): string;
|
|
46
|
+
/**
|
|
47
|
+
* Helper function to normalize a string. Specifically, this performs the following steps:
|
|
48
|
+
*
|
|
49
|
+
* - Removes any non-printable characters, if any.
|
|
50
|
+
* - Normalizes all newlines to "\n".
|
|
51
|
+
* - Normalizes all spaces to " ".
|
|
52
|
+
* - Removes leading/trailing whitespace.
|
|
53
|
+
*
|
|
54
|
+
* @see
|
|
55
|
+
* https://stackoverflow.com/questions/11598786/how-to-replace-non-printable-unicode-characters-javascript
|
|
56
|
+
*/
|
|
57
|
+
export declare function normalizeString(string: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* Helper function to parse a Semantic Versioning string into its individual constituents. Returns
|
|
60
|
+
* undefined if the submitted string was not a proper Semantic Version.
|
|
61
|
+
*
|
|
62
|
+
* @see https://semver.org/
|
|
63
|
+
*/
|
|
64
|
+
export declare function parseSemanticVersion(versionString: string): {
|
|
65
|
+
/** The first number inside of the semantic version. */
|
|
66
|
+
majorVersion: number;
|
|
67
|
+
/** The second number inside of the semantic version. */
|
|
68
|
+
minorVersion: number;
|
|
69
|
+
/** The third number inside of the semantic version. */
|
|
70
|
+
patchVersion: number;
|
|
71
|
+
} | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Helper function to remove lines from a multi-line string. This function looks for a "-start" and
|
|
74
|
+
* a "-end" suffix after the marker. Lines with markets will be completely removed from the output.
|
|
75
|
+
*
|
|
76
|
+
* For example, by using a marker of "@foo":
|
|
77
|
+
*
|
|
78
|
+
* ```text
|
|
79
|
+
* line1
|
|
80
|
+
* # @foo-start
|
|
81
|
+
* line2
|
|
82
|
+
* line3
|
|
83
|
+
* # @foo-end
|
|
84
|
+
* line4
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* Would return:
|
|
88
|
+
*
|
|
89
|
+
* ```text
|
|
90
|
+
* line1
|
|
91
|
+
* line4
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function removeLinesBetweenMarkers(string: string, marker: string): string;
|
|
95
|
+
/** Helper function to remove lines from a multi-line string matching a certain other string. */
|
|
96
|
+
export declare function removeLinesMatching(string: string, match: string): string;
|
|
97
|
+
/**
|
|
98
|
+
* Helper function to remove all non-printable characters from a string.
|
|
99
|
+
*
|
|
100
|
+
* @see
|
|
101
|
+
* https://stackoverflow.com/questions/11598786/how-to-replace-non-printable-unicode-characters-javascript
|
|
102
|
+
*/
|
|
103
|
+
export declare function removeNonPrintableCharacters(string: string): string;
|
|
104
|
+
/** Helper function to remove all whitespace characters from a string. */
|
|
105
|
+
export declare function removeWhitespace(string: string): string;
|
|
106
|
+
/**
|
|
107
|
+
* Helper function to trim a prefix from a string, if it exists. Returns the trimmed string.
|
|
108
|
+
*
|
|
109
|
+
* @param string The string to trim.
|
|
110
|
+
* @param prefix The prefix to trim.
|
|
111
|
+
* @param trimAll Whether to remove multiple instances of the prefix, if they exist. If this is set
|
|
112
|
+
* to true, the prefix must only be a single character.
|
|
113
|
+
*/
|
|
114
|
+
export declare function trimPrefix(string: string, prefix: string, trimAll?: boolean): string;
|
|
115
|
+
/** Helper function to trim a suffix from a string, if it exists. Returns the trimmed string. */
|
|
116
|
+
export declare function trimSuffix(string: string, prefix: string): string;
|
|
117
|
+
/**
|
|
118
|
+
* Helper function to truncate a string to a maximum length. If the length of the string is less
|
|
119
|
+
* than or equal to the provided maximum length, the string will be returned unmodified.
|
|
120
|
+
*/
|
|
121
|
+
export declare function truncateString(string: string, maxLength: number): string;
|
|
122
|
+
//# sourceMappingURL=string.d.ts.map
|