@dereekb/util 12.4.5 → 12.5.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/fetch/index.cjs.js +6 -1
- package/fetch/index.esm.js +6 -1
- package/fetch/package.json +1 -1
- package/fetch/src/lib/fetch.page.iterate.d.ts +16 -2
- package/index.cjs.js +5093 -4538
- package/index.esm.js +5070 -4539
- package/package.json +1 -1
- package/src/lib/array/array.d.ts +25 -0
- package/src/lib/auth/auth.role.claims.d.ts +15 -0
- package/src/lib/date/date.unix.d.ts +3 -1
- package/src/lib/getter/getter.d.ts +4 -0
- package/src/lib/number/number.d.ts +7 -1
- package/src/lib/path/path.d.ts +341 -17
- package/src/lib/promise/index.d.ts +1 -0
- package/src/lib/promise/promise.d.ts +4 -3
- package/src/lib/promise/promise.task.d.ts +63 -0
- package/src/lib/string/factory.d.ts +37 -1
- package/src/lib/string/mimetype.d.ts +30 -0
- package/src/lib/string/transform.d.ts +39 -0
- package/test/CHANGELOG.md +8 -0
- package/test/package.json +1 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { type Factory, type FactoryWithRequiredInput } from '../getter';
|
|
1
|
+
import { FactoryWithInput, type Factory, type FactoryWithRequiredInput } from '../getter';
|
|
2
|
+
import { Maybe } from '../value';
|
|
3
|
+
import { TransformStringFunctionConfig } from './transform';
|
|
2
4
|
export type StringFactory<K extends string = string> = Factory<K>;
|
|
3
5
|
export type ToStringFunction<T, K extends string = string> = FactoryWithRequiredInput<K, T>;
|
|
4
6
|
/**
|
|
@@ -9,3 +11,37 @@ export type ToStringFunction<T, K extends string = string> = FactoryWithRequired
|
|
|
9
11
|
* @returns
|
|
10
12
|
*/
|
|
11
13
|
export declare function stringFactoryFromFactory<T, K extends string = string>(factory: Factory<T>, toStringFunction: ToStringFunction<T, K>): StringFactory<K>;
|
|
14
|
+
/**
|
|
15
|
+
* A factory that returns a string based on the input date.
|
|
16
|
+
*/
|
|
17
|
+
export type StringFromDateFactory = FactoryWithInput<string, Maybe<Date>>;
|
|
18
|
+
export interface StringFromDateConfig {
|
|
19
|
+
/**
|
|
20
|
+
* The number of digits to return from the end of the generated string.
|
|
21
|
+
*
|
|
22
|
+
* Is ignored if transformStringConfig.slice is set, or the value is 0.
|
|
23
|
+
*/
|
|
24
|
+
readonly takeFromEnd?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Optional/additional transformations to apply to the string.
|
|
27
|
+
*/
|
|
28
|
+
readonly transformStringConfig?: Maybe<TransformStringFunctionConfig>;
|
|
29
|
+
/**
|
|
30
|
+
* The factory function to generate the initial string from the input date.
|
|
31
|
+
*/
|
|
32
|
+
readonly dateToString: FactoryWithRequiredInput<string, Date>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a factory that returns a string based on the input date.
|
|
36
|
+
|
|
37
|
+
* @param config Configuration for the factory.
|
|
38
|
+
* @returns A factory that returns a string based on the input date.
|
|
39
|
+
*/
|
|
40
|
+
export declare function stringFromDateFactory(config: StringFromDateConfig): StringFromDateFactory;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a factory that returns a string based on the Unix timestamp of the input date.
|
|
43
|
+
*
|
|
44
|
+
* @param digitsFromEnd The number of digits to return from the end of the generated string. Defaults to 7.
|
|
45
|
+
* @returns A StringFromDateFactory.
|
|
46
|
+
*/
|
|
47
|
+
export declare function stringFromTimeFactory(digitsFromEnd?: number): StringFromDateFactory;
|
|
@@ -1,12 +1,42 @@
|
|
|
1
|
+
import { Maybe } from '../value/maybe.type';
|
|
1
2
|
/**
|
|
2
3
|
* A simple mime type string with just the type/subtype and no parameters.
|
|
3
4
|
*
|
|
4
5
|
* I.E. "application/json"
|
|
5
6
|
*/
|
|
6
7
|
export type MimeTypeWithoutParameters = string;
|
|
8
|
+
/**
|
|
9
|
+
* The mimetype wildcard.
|
|
10
|
+
*/
|
|
11
|
+
export type MimeTypeWildcard = '*';
|
|
12
|
+
/**
|
|
13
|
+
* A mime type with a wildcard subtype. Has a star as the subtype.
|
|
14
|
+
*
|
|
15
|
+
* I.E. "application/*"
|
|
16
|
+
*/
|
|
17
|
+
export type MimeTypeWithSubtypeWildcardWithoutParameters = string;
|
|
7
18
|
/**
|
|
8
19
|
* A mime type string that may contain additional parameters.
|
|
9
20
|
*
|
|
10
21
|
* I.E. "text/plain", "application/json; charset=utf-8"
|
|
11
22
|
*/
|
|
12
23
|
export type ContentTypeMimeType = string;
|
|
24
|
+
/**
|
|
25
|
+
* Input for mimetypeForImageType().
|
|
26
|
+
*
|
|
27
|
+
* This is a non-exhaustive list of common image types.
|
|
28
|
+
*/
|
|
29
|
+
export type MimeTypeForImageTypeInputType = 'jpeg' | 'jpg' | 'png' | 'webp' | 'gif' | 'svg' | 'raw' | 'heif' | 'tiff';
|
|
30
|
+
export declare const JPEG_MIME_TYPE: MimeTypeWithoutParameters;
|
|
31
|
+
export declare const PNG_MIME_TYPE: MimeTypeWithoutParameters;
|
|
32
|
+
export declare const WEBP_MIME_TYPE: MimeTypeWithoutParameters;
|
|
33
|
+
export declare const GIF_MIME_TYPE: MimeTypeWithoutParameters;
|
|
34
|
+
export declare const HEIF_MIME_TYPE: MimeTypeWithoutParameters;
|
|
35
|
+
export declare const TIFF_MIME_TYPE: MimeTypeWithoutParameters;
|
|
36
|
+
export declare const SVG_MIME_TYPE: MimeTypeWithoutParameters;
|
|
37
|
+
export declare const RAW_MIME_TYPE: MimeTypeWithoutParameters;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the mimetype for the given image type, or undefined if the type is not known.
|
|
40
|
+
*/
|
|
41
|
+
export declare function mimetypeForImageType(imageType: MimeTypeForImageTypeInputType): MimeTypeWithoutParameters;
|
|
42
|
+
export declare function mimetypeForImageType(imageType: MimeTypeForImageTypeInputType | string): Maybe<MimeTypeWithoutParameters>;
|
|
@@ -40,6 +40,10 @@ export type TransformStringFunctionConfig<S extends string = string> = {
|
|
|
40
40
|
* This is ignored if a custom `transform` function is provided and takes precedence over `toLowercase` if both are true.
|
|
41
41
|
*/
|
|
42
42
|
readonly toUppercase?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Slices the string based on the configuration.
|
|
45
|
+
*/
|
|
46
|
+
readonly slice?: SliceStringFunctionConfig;
|
|
43
47
|
/**
|
|
44
48
|
* An optional custom function to transform the string.
|
|
45
49
|
* If provided, `toLowercase` and `toUppercase` are ignored. Trimming (if `trim` is true) occurs before this custom transform.
|
|
@@ -82,6 +86,7 @@ export declare function transformStringFunctionConfig<S extends string = string>
|
|
|
82
86
|
* Creates a string transformation function based on the provided configuration.
|
|
83
87
|
* The resulting function will apply transformations in a specific order:
|
|
84
88
|
* 1. Trimming (if `config.trim` is true).
|
|
89
|
+
* 2. Slicing (if `config.slice` is provided).
|
|
85
90
|
* 2. Custom `config.transform` function (if provided).
|
|
86
91
|
* 3. Uppercase conversion (if `config.toUppercase` is true and no `config.transform`).
|
|
87
92
|
* 4. Lowercase conversion (if `config.toLowercase` is true and no `config.transform` or `config.toUppercase`).
|
|
@@ -131,3 +136,37 @@ export type PadStartFunction = TransformStringFunction;
|
|
|
131
136
|
* @returns A function that pads the start of a string.
|
|
132
137
|
*/
|
|
133
138
|
export declare function padStartFunction(minLength: number, padCharacter: string): PadStartFunction;
|
|
139
|
+
/**
|
|
140
|
+
* Function that slices and concats parts of a string based on the configuration.
|
|
141
|
+
*/
|
|
142
|
+
export type SliceStringFunction = TransformStringFunction;
|
|
143
|
+
/**
|
|
144
|
+
* Configuration for sliceStringFunction()
|
|
145
|
+
*/
|
|
146
|
+
export interface SliceStringFunctionConfig {
|
|
147
|
+
/**
|
|
148
|
+
* The number of characters to take from the start of the string.
|
|
149
|
+
*
|
|
150
|
+
* When both fromStart and fromEnd are specified, the first N characters are concatenated with the last M characters.
|
|
151
|
+
* If the total (fromStart + fromEnd) is greater than or equal to the string length, the entire string is returned.
|
|
152
|
+
*
|
|
153
|
+
* If undefined or 0, only takes from the end of the string. The absolute value of this number is used.
|
|
154
|
+
*/
|
|
155
|
+
readonly fromStart?: number;
|
|
156
|
+
/**
|
|
157
|
+
* The number of characters to take from the end of the string.
|
|
158
|
+
*
|
|
159
|
+
* When both fromStart and fromEnd are specified, the first N characters are concatenated with the last M characters.
|
|
160
|
+
* If the total (fromStart + fromEnd) is greater than or equal to the string length, the entire string is returned.
|
|
161
|
+
*
|
|
162
|
+
* If undefined or 0, only takes from the start of the string. The absolute value of this number is used.
|
|
163
|
+
*/
|
|
164
|
+
readonly fromEnd?: number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Creates a function that slices and concats parts of a string based on the configuration.
|
|
168
|
+
*
|
|
169
|
+
* @param config The configuration for the slice function.
|
|
170
|
+
* @returns A SliceStringFunction.
|
|
171
|
+
*/
|
|
172
|
+
export declare function sliceStringFunction(config: SliceStringFunctionConfig): SliceStringFunction;
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [12.5.1](https://github.com/dereekb/dbx-components/compare/v12.5.0-dev...v12.5.1) (2025-10-14)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# [12.5.0](https://github.com/dereekb/dbx-components/compare/v12.4.5-dev...v12.5.0) (2025-10-13)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [12.4.5](https://github.com/dereekb/dbx-components/compare/v12.4.4-dev...v12.4.5) (2025-09-14)
|
|
6
14
|
|
|
7
15
|
|