@collana-solutions/javascript-utils 2.6.0 → 2.6.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 +21 -21
- package/README.md +42 -42
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js.map +1 -1
- package/package.json +82 -84
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 collana solutions AG (formerly Neolution AG)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 collana solutions AG (formerly Neolution AG)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
# javascript-utils
|
|
2
|
-
|
|
3
|
-
This is a collection of utilities that we have created to help with our development process. We have decided to open source these utilities in the hopes that they will be useful to others.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
To use these utilities, add the [@collana-solutions/javascript-utils](https://www.npmjs.com/package/@collana-solutions/javascript-utils) npm package to your project and use the desired functions in your source code.
|
|
8
|
-
|
|
9
|
-
```shell
|
|
10
|
-
npm install @collana-solutions/javascript-utils
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { newGuid } from "@collana-solutions/javascript-utils";
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Versions up to 2.6.0 were published as `@neolution-ch/javascript-utils`. That name is deprecated and gets no new releases.
|
|
18
|
-
|
|
19
|
-
## Contributing
|
|
20
|
-
|
|
21
|
-
If you would like to contribute to this project, please submit a pull request.
|
|
22
|
-
|
|
23
|
-
### Guidelines
|
|
24
|
-
|
|
25
|
-
- Use a filename that fits what the utility is doing. If you introduce a new file, choose a name that fits your utility but is still generic enough to hold similar utilities that can be added later alongside your addition.
|
|
26
|
-
- Add tests to your utilities and strive to cover many different usage scenarios and parametrization and high code coverage.
|
|
27
|
-
|
|
28
|
-
### Development
|
|
29
|
-
|
|
30
|
-
The repository uses pnpm through Corepack (`corepack enable`), with the version pinned in `package.json`. `pnpm run prepare-pr` formats, lints, builds and tests in one go.
|
|
31
|
-
|
|
32
|
-
## Releases
|
|
33
|
-
|
|
34
|
-
Due to the nature of this project as a loosely connected collection of utilities, it's important to be strict about following [SemVer](https://semver.org/) to communicate possible breaking changes to the users of this library via version number.
|
|
35
|
-
|
|
36
|
-
Equally as important is to be precise about the changes made in each release, so users of this library can see easily where changes were made. Releases follow the [collana-solutions release playbook](https://github.com/collana-solutions/release-playbook) (Changesets, public npm variant):
|
|
37
|
-
|
|
38
|
-
1. Add a changeset to your PR with `pnpm changeset`: pick the SemVer bump and describe the change for the users of this library. CI fails without one.
|
|
39
|
-
2. Merging to `main` opens or updates a **chore: version packages** PR, which bumps the version and writes the [CHANGELOG.md](CHANGELOG.md).
|
|
40
|
-
3. Merging that PR publishes the package to npm through trusted publishing and creates the GitHub Release.
|
|
41
|
-
|
|
42
|
-
Dependabot PRs get a changeset generated automatically. A manual dependency bump does not, so add one yourself.
|
|
1
|
+
# javascript-utils
|
|
2
|
+
|
|
3
|
+
This is a collection of utilities that we have created to help with our development process. We have decided to open source these utilities in the hopes that they will be useful to others.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
To use these utilities, add the [@collana-solutions/javascript-utils](https://www.npmjs.com/package/@collana-solutions/javascript-utils) npm package to your project and use the desired functions in your source code.
|
|
8
|
+
|
|
9
|
+
```shell
|
|
10
|
+
npm install @collana-solutions/javascript-utils
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { newGuid } from "@collana-solutions/javascript-utils";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Versions up to 2.6.0 were published as `@neolution-ch/javascript-utils`. That name is deprecated and gets no new releases.
|
|
18
|
+
|
|
19
|
+
## Contributing
|
|
20
|
+
|
|
21
|
+
If you would like to contribute to this project, please submit a pull request.
|
|
22
|
+
|
|
23
|
+
### Guidelines
|
|
24
|
+
|
|
25
|
+
- Use a filename that fits what the utility is doing. If you introduce a new file, choose a name that fits your utility but is still generic enough to hold similar utilities that can be added later alongside your addition.
|
|
26
|
+
- Add tests to your utilities and strive to cover many different usage scenarios and parametrization and high code coverage.
|
|
27
|
+
|
|
28
|
+
### Development
|
|
29
|
+
|
|
30
|
+
The repository uses pnpm through Corepack (`corepack enable`), with the version pinned in `package.json`. `pnpm run prepare-pr` formats, lints, builds and tests in one go.
|
|
31
|
+
|
|
32
|
+
## Releases
|
|
33
|
+
|
|
34
|
+
Due to the nature of this project as a loosely connected collection of utilities, it's important to be strict about following [SemVer](https://semver.org/) to communicate possible breaking changes to the users of this library via version number.
|
|
35
|
+
|
|
36
|
+
Equally as important is to be precise about the changes made in each release, so users of this library can see easily where changes were made. Releases follow the [collana-solutions release playbook](https://github.com/collana-solutions/release-playbook) (Changesets, public npm variant):
|
|
37
|
+
|
|
38
|
+
1. Add a changeset to your PR with `pnpm changeset`: pick the SemVer bump and describe the change for the users of this library. CI fails without one.
|
|
39
|
+
2. Merging to `main` opens or updates a **chore: version packages** PR, which bumps the version and writes the [CHANGELOG.md](CHANGELOG.md).
|
|
40
|
+
3. Merging that PR publishes the package to npm through trusted publishing and creates the GitHub Release.
|
|
41
|
+
|
|
42
|
+
Dependabot PRs get a changeset generated automatically. A manual dependency bump does not, so add one yourself.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/lib/string.ts","../src/lib/enum.ts","../src/lib/date.ts","../src/lib/guid.ts","../src/lib/localStorage.ts","../src/lib/mimeType.ts","../src/lib/object.ts","../src/lib/swissStandards.ts","../src/lib/cacheProvider.ts","../src/lib/number.ts","../src/lib/boolean.ts"],"sourcesContent":["/**\r\n * Indicates whether a specified string is null/undefined or empty\r\n * @param value The string to test\r\n * @returns true if the value parameter is null/undefined or empty\r\n */\r\nexport function isNullOrEmpty(value?: string): boolean {\r\n if (!value || typeof value !== \"string\") {\r\n return true;\r\n }\r\n\r\n return value.length === 0;\r\n}\r\n\r\n/**\r\n * Indicates whether a specified string is null/undefined, empty, or consists only of white-space characters\r\n * @param value The string to test\r\n * @returns true if the value parameter is null/undefined, Empty, or if value consists exclusively of white-space characters\r\n */\r\nexport function isNullOrWhitespace(value?: string): boolean {\r\n return isNullOrEmpty(value) || (value as string).trim().length === 0;\r\n}\r\n\r\n/**\r\n * Capitalize the string\r\n * @param value The string to capitalize\r\n * @returns The capitalized string\r\n */\r\nexport function capitalize(value?: string): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n return value.charAt(0).toUpperCase() + value.slice(1);\r\n}\r\n\r\n/**\r\n * Uncapitalize the string\r\n * @param value The string to uncapitalize\r\n * @returns The uncapitalized string\r\n */\r\nexport function uncapitalize(value?: string): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n return value.charAt(0).toLowerCase() + value.slice(1);\r\n}\r\n\r\n/**\r\n * Truncates a string to a maximum length, adding a suffix if truncated\r\n * @param value The string to truncate\r\n * @param maxLength The maximum length of the resulting string\r\n * @param suffix The suffix to append if truncated (default: \"\")\r\n * @returns The truncated string\r\n */\r\nexport function truncate(value: string | undefined, maxLength: number, suffix = \"\"): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n if (value.length <= maxLength) {\r\n return value;\r\n }\r\n\r\n return `${value.slice(0, maxLength)}${suffix}`;\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the start of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the left side\r\n */\r\nexport function trimStart(haystack: string, needle: string): string {\r\n if (isNullOrEmpty(haystack) || isNullOrEmpty(needle)) {\r\n return haystack;\r\n }\r\n\r\n let offset = 0;\r\n\r\n while (haystack.indexOf(needle, offset) === offset) {\r\n offset = offset + needle.length;\r\n }\r\n return haystack.slice(offset);\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the end of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the right side\r\n */\r\nexport function trimEnd(haystack: string, needle: string): string {\r\n if (isNullOrEmpty(haystack) || isNullOrEmpty(needle)) {\r\n return haystack;\r\n }\r\n\r\n let offset = haystack.length,\r\n idx = -1;\r\n\r\n while (true) {\r\n idx = haystack.lastIndexOf(needle, offset - 1);\r\n if (idx === -1 || idx + needle.length !== offset) {\r\n break;\r\n }\r\n if (idx === 0) {\r\n return \"\";\r\n }\r\n offset = idx;\r\n }\r\n\r\n return haystack.slice(0, offset);\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the start and the end of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the right and left side\r\n */\r\nexport function trim(haystack: string, needle: string): string {\r\n const trimmed = trimStart(haystack, needle);\r\n return trimEnd(trimmed, needle);\r\n}\r\n\r\n/**\r\n * Splits the string at line breaks\r\n * @param str the string to split\r\n * @param removeEmptyEntries the option to remove empty entries\r\n * @param trimEntries the option to trim the entries\r\n * @returns the individual lines as an array\r\n */\r\nexport function splitLines(str: string, removeEmptyEntries: boolean = false, trimEntries: boolean = false): string[] {\r\n if (isNullOrEmpty(str)) {\r\n return [];\r\n }\r\n\r\n let splitted = str.split(/\\r\\n|\\r|\\n/);\r\n\r\n if (trimEntries) {\r\n splitted = splitted.map((x) => x.trim());\r\n }\r\n\r\n if (removeEmptyEntries) {\r\n splitted = splitted.filter((line) => line.length > 0);\r\n }\r\n\r\n return splitted;\r\n}\r\n","/**\r\n * The standard enum type\r\n */\r\nexport type StandardEnum<T> = {\r\n [id: string]: T | string;\r\n [nu: number]: string;\r\n};\r\n\r\n/**\r\n * Returns the name of an enum from its value\r\n * @param enumVariable The enum for which you want to get the name\r\n * @param enumValue The value of the enum for which you want to get the name\r\n * @returns A string containing the name of the enum\r\n */\r\nexport function getEnumNameFromValue<T>(enumVariable: StandardEnum<T>, enumValue: T): string {\r\n let result = enumVariable[enumValue as keyof StandardEnum<T>] as string;\r\n\r\n if (result === undefined && isEnumString(enumVariable)) {\r\n result = Object.keys(enumVariable)[Object.values(enumVariable).indexOf(enumValue)];\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Returns the value of an enum from its name\r\n * @param enumVariable The enum for which you want to get the value\r\n * @param enumName The name of the enum for which you want to get the value\r\n * @returns A string containing the value of the enum\r\n */\r\nexport function getEnumValueFromName<T>(enumVariable: StandardEnum<T>, enumName: string): T {\r\n return enumVariable[enumName as keyof StandardEnum<T>] as T;\r\n}\r\n\r\n/**\r\n * Returns all the names of an enum\r\n * @param enumVariable The enum for which you want to get the names\r\n * @returns A string array containing the names of the enum\r\n */\r\nexport function getEnumNames<T>(enumVariable: StandardEnum<T>) {\r\n const names = Object.values(enumVariable);\r\n\r\n // If enum is with values integer, object.values returns a list of [names, values].\r\n return isEnumString(enumVariable) ? Object.keys(enumVariable) : names.slice(0, names.length / 2);\r\n}\r\n\r\n/**\r\n * Returns all the values of an enum\r\n * @param enumVariable The enum for which you want to get the values\r\n * @returns A string or number array containing the values of the enum\r\n */\r\nexport function getEnumValues<T>(enumVariable: StandardEnum<T>): T[] {\r\n const keys = Object.keys(enumVariable);\r\n\r\n // If enum is with values integer, object.keys returns a list of [values, names].\r\n return (\r\n isEnumString(enumVariable) ? Object.values(enumVariable) : keys.slice(0, keys.length / 2).map((value) => Number.parseInt(value))\r\n ) as T[];\r\n}\r\n\r\n/**\r\n * Parses a string to an enum value\r\n * @param enumVariable The enum for which you want to get the values\r\n * @param value The string to parse\r\n * @returns The enum value corresponding to the string, or undefined if not found\r\n */\r\nexport function parseEnum<T>(enumVariable: StandardEnum<T>, value: string): T | undefined {\r\n if (!isEnumString(enumVariable) && Number.isNaN(Number(value))) {\r\n return undefined;\r\n }\r\n\r\n return getEnumValueFromName(enumVariable, getEnumNameFromValue(enumVariable, value as T));\r\n}\r\n\r\n/**\r\n * Returns if it's a enum with string value\r\n * @param enumVariable The enum\r\n * @returns A bool\r\n */\r\nfunction isEnumString<T>(enumVariable: StandardEnum<T>) {\r\n for (const key in enumVariable) {\r\n return !/^\\d+$/.test(key);\r\n }\r\n\r\n return false;\r\n}\r\n","import {\r\n isDate,\r\n isValid,\r\n isFirstDayOfMonth,\r\n isLastDayOfMonth,\r\n isLeapYear,\r\n isWeekend,\r\n differenceInCalendarDays,\r\n addBusinessDays,\r\n startOfDay,\r\n endOfDay,\r\n lastDayOfYear,\r\n getQuarter as getQuarterInternal,\r\n addQuarters as addQuartersInternal,\r\n} from \"date-fns\";\r\n\r\n/**\r\n * Check whether the date is valid\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is valid\r\n */\r\nexport function dateIsValid(date: Date): boolean {\r\n return isDate(date) && isValid(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is the first day of the month\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is the first day of the month\r\n */\r\nexport function dateIsFirstDayOfMonth(date: Date): boolean {\r\n return dateIsValid(date) && isFirstDayOfMonth(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is the last day of the month\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is the last day of the month\r\n */\r\nexport function dateIsLastDayOfMonth(date: Date): boolean {\r\n return dateIsValid(date) && isLastDayOfMonth(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is a leap year\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is a leap year\r\n */\r\nexport function dateIsLeapYear(date: Date): boolean {\r\n return dateIsValid(date) && isLeapYear(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is a weekend\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is a weekend\r\n */\r\nexport function dateIsWeekend(date: Date): boolean {\r\n return dateIsValid(date) && isWeekend(date);\r\n}\r\n\r\n/**\r\n * Calculate the difference in days between two dates\r\n * The order is not relevant hence the result is always positive\r\n * @param from The start date\r\n * @param to The end date\r\n * @returns The difference in days between two dates\r\n */\r\nexport function dateDifferenceInDays(from: Date, to: Date): number {\r\n return dateIsValid(from) && dateIsValid(to) ? Math.abs(differenceInCalendarDays(from, to)) : Number.NaN;\r\n}\r\n\r\n/**\r\n * Get the next business date\r\n * @param date The date\r\n * @returns The next business date\r\n */\r\nexport function getNextBusinessDate(date: Date): Date {\r\n return dateIsValid(date) ? addBusinessDays(date, 1) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the start of a day for the given date\r\n * @param date The date\r\n * @returns The start of a day date\r\n */\r\nexport function getStartOfDay(date: Date): Date {\r\n return dateIsValid(date) ? startOfDay(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the end of a day for the given date\r\n * @param date The date\r\n * @returns The end of a day date\r\n */\r\nexport function getEndOfDay(date: Date): Date {\r\n return dateIsValid(date) ? endOfDay(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the first day of a year for the given date\r\n * @param date The date\r\n * @returns The first day of the date year\r\n */\r\nexport function getFirstDayOfYear(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getFullYear(), 0, 1) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the last day of a year for the given date\r\n * @param date The date\r\n * @returns The last day of the date year\r\n */\r\nexport function getLastDayOfYear(date: Date): Date {\r\n return dateIsValid(date) ? lastDayOfYear(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the year quarter for the given date\r\n * @param date The date\r\n * @returns The year quarter\r\n */\r\nexport function getQuarter(date: Date): number {\r\n return dateIsValid(date) ? getQuarterInternal(date) : Number.NaN;\r\n}\r\n\r\n/**\r\n * Shifts a date by a given number of quarters.\r\n * @param date The date\r\n * @param amount Number of quarters to shift by (negative values shift the date backwards)\r\n * @returns A new Date shifted by the specified number of quarters\r\n */\r\nexport function addQuarters(date: Date, amount: number): Date {\r\n return dateIsValid(date) ? addQuartersInternal(date, amount) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the date removing the time-zone offset\r\n * @param date The date\r\n * @returns the given date removing the time-zone offset\r\n */\r\nexport function getDateWithoutTimeZone(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getTime() - date.getTimezoneOffset() * 60_000) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the date adding the time-zone offset\r\n * @param date The date\r\n * @returns the given date adding the time-zone offset\r\n */\r\nexport function getDateAddTimeZone(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getTime() + date.getTimezoneOffset() * 60_000) : new Date(Number.NaN);\r\n}\r\n","import * as uuid from \"uuid\";\r\n\r\n/**\r\n * Create a new Guid (version 4 UUID)\r\n * @returns A new Guid\r\n */\r\nexport function newGuid() {\r\n return uuid.v4();\r\n}\r\n\r\n/**\r\n * Check whether a string it is a valid Guid\r\n * @param str The string to test whether it is a valid Guid\r\n * @returns A value indicating whether the string is a valid Guid\r\n */\r\nexport function isValidGuid(str: string) {\r\n const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\r\n return typeof str === \"string\" && regex.test(str);\r\n}\r\n\r\n/**\r\n * The empty Guid (an identifier containing all zeros)\r\n */\r\nexport const emptyGuid: string = uuid.NIL;\r\n","import { dateIsValid } from \"./date\";\r\n\r\n/**\r\n * The localStorage item\r\n */\r\ninterface LocalStorageItem<T> {\r\n /**\r\n * The data\r\n */\r\n data: T;\r\n\r\n /**\r\n * The expiration date\r\n */\r\n expirationDate?: Date;\r\n}\r\n\r\n/**\r\n * Check if the localStorage is supported\r\n */\r\nconst checkLocalStorageSupport = () => {\r\n if (typeof localStorage === \"undefined\") {\r\n throw new TypeError(\"localStorage not supported\");\r\n }\r\n};\r\n\r\n/**\r\n * Get an item from the localStorage\r\n * @param key The key\r\n * @returns The item\r\n */\r\nexport function getLocalStorageItem<T>(key: string): T | undefined {\r\n checkLocalStorageSupport();\r\n\r\n const item = localStorage.getItem(key);\r\n if (!item) {\r\n return undefined;\r\n }\r\n\r\n const parsedItem = JSON.parse(item) as LocalStorageItem<T>;\r\n\r\n if (parsedItem.expirationDate) {\r\n const revivedExpirationDate = new Date(parsedItem.expirationDate);\r\n if (dateIsValid(revivedExpirationDate) && revivedExpirationDate < new Date()) {\r\n localStorage.removeItem(key);\r\n return undefined;\r\n }\r\n }\r\n\r\n return parsedItem.data;\r\n}\r\n\r\n/**\r\n * Set an item in the localStorage\r\n * @param key The key\r\n * @param data The item data\r\n * @param expirationDate The expiration date\r\n */\r\nexport function setLocalStorageItem<T>(key: string, data: T, expirationDate?: Date): void {\r\n checkLocalStorageSupport();\r\n localStorage.setItem(key, JSON.stringify({ data, expirationDate }));\r\n}\r\n\r\n/**\r\n * Remove an item from the localStorage\r\n * @param key The key\r\n */\r\nexport function removeLocalStorageItem(key: string): void {\r\n checkLocalStorageSupport();\r\n localStorage.removeItem(key);\r\n}\r\n","import { isNullOrEmpty } from \"./string\";\r\n\r\n/**\r\n * Private helper function to check if a MIME type matches a main type pattern\r\n * @param mimeType The MIME type to check\r\n * @param mainType The main MIME type (e.g., \"image\", \"video\")\r\n * @returns true if the MIME type matches the pattern\r\n */\r\nfunction isMainMimeType(mimeType: string, mainType: string): boolean {\r\n const normalizedMimeType = mimeType.toLowerCase().trim();\r\n return normalizedMimeType.startsWith(`${mainType}/`) && normalizedMimeType.length > mainType.length + 1;\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents an image\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for an image\r\n */\r\nexport function isImageMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n return isMainMimeType(mimeType!, \"image\");\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents a PDF document\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for a PDF document\r\n */\r\nexport function isPdfMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n const normalizedMimeType = mimeType!.toLowerCase().trim();\r\n return normalizedMimeType === \"application/pdf\";\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents a video\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for a video\r\n */\r\nexport function isVideoMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n return isMainMimeType(mimeType!, \"video\");\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents an audio file\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for an audio file\r\n */\r\nexport function isAudioMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n return isMainMimeType(mimeType!, \"audio\");\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents a text file\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for a text file\r\n */\r\nexport function isTextMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n return isMainMimeType(mimeType!, \"text\");\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents an application file\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for an application file\r\n */\r\nexport function isApplicationMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n return isMainMimeType(mimeType!, \"application\");\r\n}\r\n","/**\r\n * Check whether the provided parameter is of type `object` but not `null`, an `array`, a `regexp`, nor a `date`\r\n * @param obj The object\r\n * @returns A boolean indicating whether the parameter is an object\r\n */\r\nexport const isObject = (obj: object): boolean =>\r\n typeof obj === \"object\" && obj !== null && !Array.isArray(obj) && !(obj instanceof RegExp) && !(obj instanceof Date);\r\n\r\n/**\r\n * Convert null properties to undefined\r\n * @param obj The object\r\n */\r\nexport const convertNullToUndefined = (obj: object | object[]): void => {\r\n if (Array.isArray(obj)) {\r\n for (const item of obj as unknown as object[]) {\r\n if (item === null) {\r\n obj[obj.indexOf(item)] = undefined;\r\n } else if (isObject(item)) {\r\n convertNullToUndefined(item);\r\n }\r\n }\r\n } else if (!isObject(obj)) {\r\n return;\r\n }\r\n\r\n for (const key of Object.keys(obj)) {\r\n const value = obj[key as keyof typeof obj];\r\n if (value === null) {\r\n delete obj[key as keyof typeof obj];\r\n } else if (isObject(value) || Array.isArray(value)) {\r\n convertNullToUndefined(value);\r\n }\r\n }\r\n};\r\n","import { isNullOrWhitespace } from \"./string\";\r\n\r\n/**\r\n * Checks if the provided string is a valid swiss IBAN number\r\n * @param ibanNumber The provided IBAN number to check\r\n * Must be in one of the following formats:\r\n * - \"CHXX XXXX XXXX XXXX XXXX X\" with whitespaces\r\n * - \"CHXXXXXXXXXXXXXXXXXXX\" without whitespaces\r\n * @returns The result of the IBAN number check\r\n */\r\nexport function isValidSwissIbanNumber(ibanNumber: string): boolean {\r\n // 1. Reject null, undefined or whitespace-only strings\r\n if (isNullOrWhitespace(ibanNumber)) {\r\n return false;\r\n }\r\n\r\n // 2. Define allowed strict formats\r\n // - with spaces: \"CHXX XXXX XXXX XXXX XXXX X\"\r\n const compactIbanNumberWithWhiteSpaces = new RegExp(/^CH[0-9]{2} [0-9]{4} [0-9][A-Z0-9]{3} [A-Z0-9]{4} [A-Z0-9]{4} [A-Z0-9]$/);\r\n // - without spaces: \"CHXXXXXXXXXXXXXXXXXXX\"\r\n const compactIbanNumberWithoutWhiteSpaces = new RegExp(/^CH[0-9]{7}[A-Z0-9]{12}$/);\r\n\r\n // 3. Check if the input matches one of the allowed formats\r\n if (!(compactIbanNumberWithWhiteSpaces.test(ibanNumber) || compactIbanNumberWithoutWhiteSpaces.test(ibanNumber))) {\r\n return false;\r\n }\r\n\r\n // 4. Remove all spaces to get a compact IBAN string\r\n const compactIbanNumber = ibanNumber.replaceAll(\" \", \"\");\r\n\r\n // 5. Rearrange IBAN for checksum calculation\r\n // - move first 4 characters (CH + 2 check digits) to the end\r\n const rearrangedIban = compactIbanNumber.slice(4) + compactIbanNumber.slice(0, 4);\r\n\r\n // 6. Replace letters with numbers (A=10, B=11, ..., Z=35)\r\n const numericStr = rearrangedIban.replaceAll(/[A-Z]/g, (ch) => (ch.codePointAt(0)! - 55).toString());\r\n\r\n // 7. Perform modulo 97 calculation to validate IBAN\r\n let restOfCalculation = 0;\r\n for (const digit of numericStr) {\r\n restOfCalculation = (restOfCalculation * 10 + Number(digit)) % 97;\r\n }\r\n\r\n // 8. IBAN is valid only if the remainder equals 1\r\n return restOfCalculation === 1;\r\n}\r\n\r\n/**\r\n * Validation of a social insurance number with checking the checksum\r\n * Validation according to https://www.sozialversicherungsnummer.ch/aufbau-neu.htm\r\n * @param socialInsuranceNumber The social insurance number to check\r\n * Must be in one of the following formats:\r\n * - \"756.XXXX.XXXX.XX\" with dots as separators\r\n * - \"756XXXXXXXXXX\" with digits only\r\n * @returns The result if the social insurance number is valid or not\r\n */\r\nexport function isValidSwissSocialInsuranceNumber(socialInsuranceNumber: string): boolean {\r\n // 1. Check if the input is empty or only a whitespace\r\n if (isNullOrWhitespace(socialInsuranceNumber)) {\r\n return false;\r\n }\r\n\r\n /**\r\n * 2. Check if the input matches one of the accepted formats:\r\n * - With dots: 756.XXXX.XXXX.XX\r\n * - Without dots: 756XXXXXXXXXX\r\n */\r\n const socialInsuranceNumberWithDots = new RegExp(/^756\\.\\d{4}\\.\\d{4}\\.\\d{2}$/);\r\n const socialInsuranceNumberWithoutDots = new RegExp(/^756\\d{10}$/);\r\n\r\n if (!socialInsuranceNumberWithDots.test(socialInsuranceNumber) && !socialInsuranceNumberWithoutDots.test(socialInsuranceNumber)) {\r\n return false;\r\n }\r\n\r\n // 3. Remove all dots → get a string of 13 digits\r\n const compactNumber = socialInsuranceNumber.replaceAll(\".\", \"\");\r\n\r\n /**\r\n * 4. Separate digits for checksum calculation\r\n * - first 12 digits: used to calculate checksum\r\n * - last digit: actual check digit\r\n */\r\n const digits = compactNumber.slice(0, -1);\r\n const reversedDigits = [...digits].reverse().join(\"\");\r\n const reversedDigitsArray = [...reversedDigits];\r\n\r\n /*\r\n * 5. Calculate weighted sum for checksum\r\n * - Even positions (after reversing) ×3\r\n * - Odd positions ×1\r\n */\r\n let sum = 0;\r\n for (const [i, element] of reversedDigitsArray.entries()) {\r\n sum += i % 2 === 0 ? Number(element) * 3 : Number(element) * 1;\r\n }\r\n\r\n /*\r\n * 6. Calculate expected check digit\r\n * - Check digit = value to reach next multiple of 10\r\n */\r\n const checksum = (10 - (sum % 10)) % 10;\r\n const checknumber = Number.parseInt(compactNumber.slice(-1));\r\n\r\n /*\r\n * 7. Compare calculated check digit with actual last digit\r\n * - If equal → valid AHV number\r\n */\r\n return checksum === checknumber;\r\n}\r\n\r\n/**\r\n * Attempts to parse and validate a Swiss IBAN.\r\n * @param unformattedIbanNumber - The unformatted IBAN as a string\r\n * @returns The result object with the following properties:\r\n * @property {boolean} isValid - Indicates whether the IBAN is valid or not\r\n * @property {string} iban - The cleaned IBAN, only present if valid\r\n * @property {string} ibanFormatted - The formatted IBAN, only present if valid\r\n */\r\nexport function tryParseSwissIbanNumber(unformattedIbanNumber?: string): {\r\n /**\r\n * Indicates whether the IBAN is valid or not\r\n */\r\n isValid: boolean;\r\n /**\r\n * The cleaned IBAN, only present if valid\r\n */\r\n iban?: string;\r\n /**\r\n * The formatted IBAN, only present if valid\r\n */\r\n ibanFormatted?: string;\r\n} {\r\n if (isNullOrWhitespace(unformattedIbanNumber)) {\r\n return { isValid: false };\r\n }\r\n\r\n const iban = unformattedIbanNumber!.replaceAll(/[^A-Z0-9]/gi, \"\").toUpperCase();\r\n const isValid = isValidSwissIbanNumber(iban);\r\n\r\n return {\r\n isValid: isValid,\r\n iban: isValid ? iban : undefined,\r\n ibanFormatted: isValid ? iban.match(/.{1,4}/g)?.join(\" \") : undefined,\r\n };\r\n}\r\n\r\n/**\r\n * Attempts to parse and validate a Swiss social insurance number.\r\n * @param unformattedInsuranceNumber - The unformatted Swiss social insurance number\r\n * @returns The result object with the following properties:\r\n * @property {boolean} isValid - Indicates whether the Swiss social insurance number is valid or not\r\n * @property {string} swissSocialInsuranceNumber - The cleaned Swiss social insurance number, only present if valid\r\n * @property {string} swissSocialInsuranceNumberFormatted - The formatted Swiss social insurance number, only present if valid\r\n */\r\nexport function tryParseSwissSocialInsuranceNumber(unformattedInsuranceNumber?: string): {\r\n /**\r\n * Indicates whether the Swiss social insurance number is valid or not\r\n */\r\n isValid: boolean;\r\n /**\r\n * The cleaned Swiss social insurance number, only present if valid\r\n */\r\n swissSocialInsuranceNumber?: string;\r\n /**\r\n * The formatted Swiss social insurance number, only present if valid\r\n */\r\n swissSocialInsuranceNumberFormatted?: string;\r\n} {\r\n if (isNullOrWhitespace(unformattedInsuranceNumber)) {\r\n return { isValid: false };\r\n }\r\n\r\n const insuranceNumber = unformattedInsuranceNumber!.replaceAll(/\\D/g, \"\");\r\n const isValid = isValidSwissSocialInsuranceNumber(insuranceNumber);\r\n\r\n return {\r\n isValid: isValid,\r\n swissSocialInsuranceNumber: isValid ? insuranceNumber : undefined,\r\n swissSocialInsuranceNumberFormatted: isValid ? insuranceNumber.replace(/^(\\d{3})(\\d{4})(\\d{4})(\\d{2})$/, \"$1.$2.$3.$4\") : undefined,\r\n };\r\n}\r\n","import { getEnumNameFromValue, StandardEnum } from \"./enum\";\r\nimport { isNullOrWhitespace } from \"./string\";\r\n\r\n/**\r\n * Methods to help caching data of any type.\r\n * Data is put in containers and may be identified by a string key.\r\n * Data can be saved, retrieved and reset.\r\n * Based on Neolution.Abstractions.Caching.CacheProvider<TEnum>\r\n * Ref: https://github.com/neolution-ch/Neolution.Abstractions/blob/main/Neolution.Abstractions/Caching/CacheProvider.cs\r\n */\r\nexport class CacheProvider<TEnum> {\r\n /**\r\n * The enum variable\r\n */\r\n private readonly enumVariable: StandardEnum<TEnum>;\r\n\r\n /**\r\n * The name of the cache\r\n */\r\n private readonly cacheName: string;\r\n\r\n /**\r\n * The cache\r\n */\r\n private readonly cache = new Map<string, object>();\r\n\r\n /**\r\n * Initializes a new instance of the CacheProvider<TEnum> class\r\n * @param enumVariable The enum variable\r\n * @param cacheName The name of the cache\r\n */\r\n constructor(enumVariable: StandardEnum<TEnum>, cacheName: string) {\r\n this.enumVariable = enumVariable;\r\n this.cacheName = cacheName;\r\n }\r\n\r\n /**\r\n * Creates the cache key\r\n * @param container The container\r\n * @param key The key\r\n * @returns The cache key\r\n */\r\n private createCacheKey(container: TEnum, key?: string): string {\r\n let containerName = getEnumNameFromValue(this.enumVariable, container);\r\n\r\n if (key && !isNullOrWhitespace(key)) {\r\n containerName = `${containerName}_${key}`;\r\n }\r\n\r\n return `${this.cacheName}:${containerName}`;\r\n }\r\n\r\n /**\r\n * Gets cached data from the specified container\r\n * @param container The container\r\n * @param key The key\r\n * @returns The data from cache\r\n */\r\n getObject<T>(container: TEnum, key?: string): T | undefined {\r\n return this.cache.get(this.createCacheKey(container, key)) as T;\r\n }\r\n\r\n /**\r\n * Sets cached data identified by a key in the specified container\r\n * @param container The container\r\n * @param key The key\r\n * @param cacheObject The cache object\r\n */\r\n setObject<T>(container: TEnum, key: string | undefined, cacheObject: T): void {\r\n this.cache.set(this.createCacheKey(container, key), cacheObject as object);\r\n }\r\n\r\n /**\r\n * Resets cached data identified by a key of the specified container\r\n * @param container The container\r\n * @param key The key\r\n */\r\n reset(container: TEnum, key?: string): void {\r\n this.cache.delete(this.createCacheKey(container, key));\r\n }\r\n}\r\n","/**\r\n * Returns a number whose value is limited to the given range\r\n * @param value The initial value\r\n * @param min The lower boundary\r\n * @param max The upper boundary\r\n * @returns A number in the range (min, max)\r\n */\r\nexport function clamp(value: number, min: number, max: number): number {\r\n if (min > max) {\r\n throw new Error(`'${min}' cannot be greater than '${max}'.`);\r\n }\r\n return Math.min(Math.max(value, min), max);\r\n}\r\n\r\n/**\r\n * Round a number with the specified precision\r\n * @param value The number to round\r\n * @param precision The desired precision\r\n * @returns The number rounded with the specified precision\r\n */\r\nexport function roundPrecision(value: number, precision: number): number {\r\n const multiplier = Math.pow(10, precision);\r\n return Math.round(value * multiplier) / multiplier;\r\n}\r\n","import { isNullOrEmpty } from \"./string\";\r\n\r\n/**\r\n * Converts a string to a boolean\r\n * @param value The string to convert\r\n * @returns The parsed boolean\r\n */\r\nexport function parseBool(value?: string): boolean {\r\n // Similar to C# implementation that trims also null characters\r\n // https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Boolean.cs#L277\r\n return !isNullOrEmpty(value) && value?.replace(/[\\s\\0]/g, \"\").toLowerCase() === \"true\";\r\n}\r\n"],"names":["isNullOrEmpty","value","length","isNullOrWhitespace","trim","trimStart","haystack","needle","offset","indexOf","slice","trimEnd","idx","lastIndexOf","getEnumNameFromValue","enumVariable","enumValue","result","undefined","isEnumString","Object","keys","values","getEnumValueFromName","enumName","key","test","dateIsValid","date","isDate","isValid","emptyGuid","uuid","NIL","checkLocalStorageSupport","localStorage","TypeError","isMainMimeType","mimeType","mainType","normalizedMimeType","toLowerCase","startsWith","isObject","obj","Array","isArray","RegExp","Date","convertNullToUndefined","item","isValidSwissIbanNumber","ibanNumber","compactIbanNumberWithWhiteSpaces","compactIbanNumberWithoutWhiteSpaces","compactIbanNumber","replaceAll","numericStr","ch","codePointAt","toString","restOfCalculation","digit","Number","isValidSwissSocialInsuranceNumber","socialInsuranceNumber","socialInsuranceNumberWithDots","socialInsuranceNumberWithoutDots","compactNumber","reversedDigitsArray","reverse","join","sum","i","element","entries","parseInt","cacheName","cache","Map","constructor","this","createCacheKey","container","containerName","getObject","get","setObject","cacheObject","set","reset","delete","amount","addQuartersInternal","NaN","charAt","toUpperCase","min","max","Error","Math","from","to","abs","differenceInCalendarDays","isFirstDayOfMonth","isLastDayOfMonth","isLeapYear","isWeekend","getTime","getTimezoneOffset","endOfDay","names","map","getFullYear","lastDayOfYear","getItem","parsedItem","JSON","parse","expirationDate","revivedExpirationDate","removeItem","data","addBusinessDays","getQuarterInternal","startOfDay","str","v4","replace","isNaN","precision","multiplier","pow","round","setItem","stringify","removeEmptyEntries","trimEntries","splitted","split","x","filter","line","maxLength","suffix","unformattedIbanNumber","iban","ibanFormatted","match","unformattedInsuranceNumber","insuranceNumber","swissSocialInsuranceNumber","swissSocialInsuranceNumberFormatted"],"mappings":"+VAKM,SAAUA,EAAcC,GAC5B,OAAKA,GAA0B,iBAAVA,GAIG,IAAjBA,EAAMC,MACf,CAOM,SAAUC,EAAmBF,GACjC,OAAOD,EAAcC,IAA8C,IAAnCA,EAAiBG,OAAOF,MAC1D,CAqDgB,SAAAG,EAAUC,EAAkBC,GAC1C,GAAIP,EAAcM,IAAaN,EAAcO,GAC3C,OAAOD,EAGT,IAAIE,EAAS,EAEb,KAAOF,EAASG,QAAQF,EAAQC,KAAYA,GAC1CA,GAAkBD,EAAOL,OAE3B,OAAOI,EAASI,MAAMF,EACxB,CAQgB,SAAAG,EAAQL,EAAkBC,GACxC,GAAIP,EAAcM,IAAaN,EAAcO,GAC3C,OAAOD,EAGT,IAAIE,EAASF,EAASJ,OACpBU,GAAO,EAET,KACEA,EAAMN,EAASO,YAAYN,EAAQC,EAAS,IAC/B,IAATI,GAAcA,EAAML,EAAOL,SAAWM,GAF/B,CAKX,GAAY,IAARI,EACF,MAAO,GAETJ,EAASI,CACV,CAED,OAAON,EAASI,MAAM,EAAGF,EAC3B,CClGgB,SAAAM,EAAwBC,EAA+BC,GACrE,IAAIC,EAASF,EAAaC,GAM1B,YAJe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rI,EAAkBC,GAErC,OAAOI,EADSN,EAAUC,EAAUC,GACZA,EAC1B,yDApEM,SAAmBN,EAA2B+I,EAAmBC,EAAS,IAC9E,OAAKhJ,GAASE,EAAmBF,IAI7BA,EAAMC,QAAU8I,EAHX/I,EAOF,GAAGA,EAAMS,MAAM,EAAGsI,KAAaC,GACxC,kCOqDM,SAAkCC,GActC,GAAI/I,EAAmB+I,GACrB,MAAO,CAAEpH,SAAS,GAGpB,MAAMqH,EAAOD,EAAuB1F,WAAW,cAAe,IAAIwC,cAC5DlE,EAAUqB,EAAuBgG,GAEvC,MAAO,CACLrH,QAASA,EACTqH,KAAMrH,EAAUqH,OAAOjI,EACvBkI,cAAetH,EAAUqH,EAAKE,MAAM,YAAY9E,KAAK,UAAOrD,EAEhE,6CAUM,SAA6CoI,GAcjD,GAAInJ,EAAmBmJ,GACrB,MAAO,CAAExH,SAAS,GAGpB,MAAMyH,EAAkBD,EAA4B9F,WAAW,MAAO,IAChE1B,EAAUkC,EAAkCuF,GAElD,MAAO,CACLzH,QAASA,EACT0H,2BAA4B1H,EAAUyH,OAAkBrI,EACxDuI,oCAAqC3H,EAAUyH,EAAgBtB,QAAQ,iCAAkC,oBAAiB/G,EAE9H,uBP5IM,SAAuBjB,GAC3B,OAAKA,GAASE,EAAmBF,GACxBA,EAGFA,EAAM8F,OAAO,GAAGtD,cAAgBxC,EAAMS,MAAM,EACrD"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/lib/string.ts","../src/lib/enum.ts","../src/lib/date.ts","../src/lib/guid.ts","../src/lib/localStorage.ts","../src/lib/mimeType.ts","../src/lib/object.ts","../src/lib/swissStandards.ts","../src/lib/cacheProvider.ts","../src/lib/number.ts","../src/lib/boolean.ts"],"sourcesContent":["/**\r\n * Indicates whether a specified string is null/undefined or empty\r\n * @param value The string to test\r\n * @returns true if the value parameter is null/undefined or empty\r\n */\r\nexport function isNullOrEmpty(value?: string): boolean {\r\n if (!value || typeof value !== \"string\") {\r\n return true;\r\n }\r\n\r\n return value.length === 0;\r\n}\r\n\r\n/**\r\n * Indicates whether a specified string is null/undefined, empty, or consists only of white-space characters\r\n * @param value The string to test\r\n * @returns true if the value parameter is null/undefined, Empty, or if value consists exclusively of white-space characters\r\n */\r\nexport function isNullOrWhitespace(value?: string): boolean {\r\n return isNullOrEmpty(value) || (value as string).trim().length === 0;\r\n}\r\n\r\n/**\r\n * Capitalize the string\r\n * @param value The string to capitalize\r\n * @returns The capitalized string\r\n */\r\nexport function capitalize(value?: string): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n return value.charAt(0).toUpperCase() + value.slice(1);\r\n}\r\n\r\n/**\r\n * Uncapitalize the string\r\n * @param value The string to uncapitalize\r\n * @returns The uncapitalized string\r\n */\r\nexport function uncapitalize(value?: string): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n return value.charAt(0).toLowerCase() + value.slice(1);\r\n}\r\n\r\n/**\r\n * Truncates a string to a maximum length, adding a suffix if truncated\r\n * @param value The string to truncate\r\n * @param maxLength The maximum length of the resulting string\r\n * @param suffix The suffix to append if truncated (default: \"\")\r\n * @returns The truncated string\r\n */\r\nexport function truncate(value: string | undefined, maxLength: number, suffix = \"\"): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n if (value.length <= maxLength) {\r\n return value;\r\n }\r\n\r\n return `${value.slice(0, maxLength)}${suffix}`;\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the start of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the left side\r\n */\r\nexport function trimStart(haystack: string, needle: string): string {\r\n if (isNullOrEmpty(haystack) || isNullOrEmpty(needle)) {\r\n return haystack;\r\n }\r\n\r\n let offset = 0;\r\n\r\n while (haystack.indexOf(needle, offset) === offset) {\r\n offset = offset + needle.length;\r\n }\r\n return haystack.slice(offset);\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the end of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the right side\r\n */\r\nexport function trimEnd(haystack: string, needle: string): string {\r\n if (isNullOrEmpty(haystack) || isNullOrEmpty(needle)) {\r\n return haystack;\r\n }\r\n\r\n let offset = haystack.length,\r\n idx = -1;\r\n\r\n while (true) {\r\n idx = haystack.lastIndexOf(needle, offset - 1);\r\n if (idx === -1 || idx + needle.length !== offset) {\r\n break;\r\n }\r\n if (idx === 0) {\r\n return \"\";\r\n }\r\n offset = idx;\r\n }\r\n\r\n return haystack.slice(0, offset);\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the start and the end of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the right and left side\r\n */\r\nexport function trim(haystack: string, needle: string): string {\r\n const trimmed = trimStart(haystack, needle);\r\n return trimEnd(trimmed, needle);\r\n}\r\n\r\n/**\r\n * Splits the string at line breaks\r\n * @param str the string to split\r\n * @param removeEmptyEntries the option to remove empty entries\r\n * @param trimEntries the option to trim the entries\r\n * @returns the individual lines as an array\r\n */\r\nexport function splitLines(str: string, removeEmptyEntries: boolean = false, trimEntries: boolean = false): string[] {\r\n if (isNullOrEmpty(str)) {\r\n return [];\r\n }\r\n\r\n let splitted = str.split(/\\r\\n|\\r|\\n/);\r\n\r\n if (trimEntries) {\r\n splitted = splitted.map((x) => x.trim());\r\n }\r\n\r\n if (removeEmptyEntries) {\r\n splitted = splitted.filter((line) => line.length > 0);\r\n }\r\n\r\n return splitted;\r\n}\r\n","/**\n * The standard enum type\n */\nexport type StandardEnum<T> = {\n [id: string]: T | string;\n [nu: number]: string;\n};\n\n/**\n * Returns the name of an enum from its value\n * @param enumVariable The enum for which you want to get the name\n * @param enumValue The value of the enum for which you want to get the name\n * @returns A string containing the name of the enum\n */\nexport function getEnumNameFromValue<T>(enumVariable: StandardEnum<T>, enumValue: T): string {\n let result = enumVariable[enumValue as keyof StandardEnum<T>] as string;\n\n if (result === undefined && isEnumString(enumVariable)) {\n result = Object.keys(enumVariable)[Object.values(enumVariable).indexOf(enumValue)];\n }\n\n return result;\n}\n\n/**\n * Returns the value of an enum from its name\n * @param enumVariable The enum for which you want to get the value\n * @param enumName The name of the enum for which you want to get the value\n * @returns A string containing the value of the enum\n */\nexport function getEnumValueFromName<T>(enumVariable: StandardEnum<T>, enumName: string): T {\n return enumVariable[enumName as keyof StandardEnum<T>] as T;\n}\n\n/**\n * Returns all the names of an enum\n * @param enumVariable The enum for which you want to get the names\n * @returns A string array containing the names of the enum\n */\nexport function getEnumNames<T>(enumVariable: StandardEnum<T>) {\n const names = Object.values(enumVariable);\n\n // If enum is with values integer, object.values returns a list of [names, values].\n return isEnumString(enumVariable) ? Object.keys(enumVariable) : names.slice(0, names.length / 2);\n}\n\n/**\n * Returns all the values of an enum\n * @param enumVariable The enum for which you want to get the values\n * @returns A string or number array containing the values of the enum\n */\nexport function getEnumValues<T>(enumVariable: StandardEnum<T>): T[] {\n const keys = Object.keys(enumVariable);\n\n // If enum is with values integer, object.keys returns a list of [values, names].\n return (\n isEnumString(enumVariable) ? Object.values(enumVariable) : keys.slice(0, keys.length / 2).map((value) => Number.parseInt(value))\n ) as T[];\n}\n\n/**\n * Parses a string to an enum value\n * @param enumVariable The enum for which you want to get the values\n * @param value The string to parse\n * @returns The enum value corresponding to the string, or undefined if not found\n */\nexport function parseEnum<T>(enumVariable: StandardEnum<T>, value: string): T | undefined {\n if (!isEnumString(enumVariable) && Number.isNaN(Number(value))) {\n return undefined;\n }\n\n return getEnumValueFromName(enumVariable, getEnumNameFromValue(enumVariable, value as T));\n}\n\n/**\n * Returns if it's a enum with string value\n * @param enumVariable The enum\n * @returns A bool\n */\nfunction isEnumString<T>(enumVariable: StandardEnum<T>) {\n for (const key in enumVariable) {\n return !/^\\d+$/.test(key);\n }\n\n return false;\n}\n","import {\r\n isDate,\r\n isValid,\r\n isFirstDayOfMonth,\r\n isLastDayOfMonth,\r\n isLeapYear,\r\n isWeekend,\r\n differenceInCalendarDays,\r\n addBusinessDays,\r\n startOfDay,\r\n endOfDay,\r\n lastDayOfYear,\r\n getQuarter as getQuarterInternal,\r\n addQuarters as addQuartersInternal,\r\n} from \"date-fns\";\r\n\r\n/**\r\n * Check whether the date is valid\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is valid\r\n */\r\nexport function dateIsValid(date: Date): boolean {\r\n return isDate(date) && isValid(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is the first day of the month\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is the first day of the month\r\n */\r\nexport function dateIsFirstDayOfMonth(date: Date): boolean {\r\n return dateIsValid(date) && isFirstDayOfMonth(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is the last day of the month\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is the last day of the month\r\n */\r\nexport function dateIsLastDayOfMonth(date: Date): boolean {\r\n return dateIsValid(date) && isLastDayOfMonth(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is a leap year\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is a leap year\r\n */\r\nexport function dateIsLeapYear(date: Date): boolean {\r\n return dateIsValid(date) && isLeapYear(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is a weekend\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is a weekend\r\n */\r\nexport function dateIsWeekend(date: Date): boolean {\r\n return dateIsValid(date) && isWeekend(date);\r\n}\r\n\r\n/**\r\n * Calculate the difference in days between two dates\r\n * The order is not relevant hence the result is always positive\r\n * @param from The start date\r\n * @param to The end date\r\n * @returns The difference in days between two dates\r\n */\r\nexport function dateDifferenceInDays(from: Date, to: Date): number {\r\n return dateIsValid(from) && dateIsValid(to) ? Math.abs(differenceInCalendarDays(from, to)) : Number.NaN;\r\n}\r\n\r\n/**\r\n * Get the next business date\r\n * @param date The date\r\n * @returns The next business date\r\n */\r\nexport function getNextBusinessDate(date: Date): Date {\r\n return dateIsValid(date) ? addBusinessDays(date, 1) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the start of a day for the given date\r\n * @param date The date\r\n * @returns The start of a day date\r\n */\r\nexport function getStartOfDay(date: Date): Date {\r\n return dateIsValid(date) ? startOfDay(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the end of a day for the given date\r\n * @param date The date\r\n * @returns The end of a day date\r\n */\r\nexport function getEndOfDay(date: Date): Date {\r\n return dateIsValid(date) ? endOfDay(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the first day of a year for the given date\r\n * @param date The date\r\n * @returns The first day of the date year\r\n */\r\nexport function getFirstDayOfYear(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getFullYear(), 0, 1) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the last day of a year for the given date\r\n * @param date The date\r\n * @returns The last day of the date year\r\n */\r\nexport function getLastDayOfYear(date: Date): Date {\r\n return dateIsValid(date) ? lastDayOfYear(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the year quarter for the given date\r\n * @param date The date\r\n * @returns The year quarter\r\n */\r\nexport function getQuarter(date: Date): number {\r\n return dateIsValid(date) ? getQuarterInternal(date) : Number.NaN;\r\n}\r\n\r\n/**\r\n * Shifts a date by a given number of quarters.\r\n * @param date The date\r\n * @param amount Number of quarters to shift by (negative values shift the date backwards)\r\n * @returns A new Date shifted by the specified number of quarters\r\n */\r\nexport function addQuarters(date: Date, amount: number): Date {\r\n return dateIsValid(date) ? addQuartersInternal(date, amount) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the date removing the time-zone offset\r\n * @param date The date\r\n * @returns the given date removing the time-zone offset\r\n */\r\nexport function getDateWithoutTimeZone(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getTime() - date.getTimezoneOffset() * 60_000) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the date adding the time-zone offset\r\n * @param date The date\r\n * @returns the given date adding the time-zone offset\r\n */\r\nexport function getDateAddTimeZone(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getTime() + date.getTimezoneOffset() * 60_000) : new Date(Number.NaN);\r\n}\r\n","import * as uuid from \"uuid\";\n\n/**\n * Create a new Guid (version 4 UUID)\n * @returns A new Guid\n */\nexport function newGuid() {\n return uuid.v4();\n}\n\n/**\n * Check whether a string it is a valid Guid\n * @param str The string to test whether it is a valid Guid\n * @returns A value indicating whether the string is a valid Guid\n */\nexport function isValidGuid(str: string) {\n const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n return typeof str === \"string\" && regex.test(str);\n}\n\n/**\n * The empty Guid (an identifier containing all zeros)\n */\nexport const emptyGuid: string = uuid.NIL;\n","import { dateIsValid } from \"./date\";\r\n\r\n/**\r\n * The localStorage item\r\n */\r\ninterface LocalStorageItem<T> {\r\n /**\r\n * The data\r\n */\r\n data: T;\r\n\r\n /**\r\n * The expiration date\r\n */\r\n expirationDate?: Date;\r\n}\r\n\r\n/**\r\n * Check if the localStorage is supported\r\n */\r\nconst checkLocalStorageSupport = () => {\r\n if (typeof localStorage === \"undefined\") {\r\n throw new TypeError(\"localStorage not supported\");\r\n }\r\n};\r\n\r\n/**\r\n * Get an item from the localStorage\r\n * @param key The key\r\n * @returns The item\r\n */\r\nexport function getLocalStorageItem<T>(key: string): T | undefined {\r\n checkLocalStorageSupport();\r\n\r\n const item = localStorage.getItem(key);\r\n if (!item) {\r\n return undefined;\r\n }\r\n\r\n const parsedItem = JSON.parse(item) as LocalStorageItem<T>;\r\n\r\n if (parsedItem.expirationDate) {\r\n const revivedExpirationDate = new Date(parsedItem.expirationDate);\r\n if (dateIsValid(revivedExpirationDate) && revivedExpirationDate < new Date()) {\r\n localStorage.removeItem(key);\r\n return undefined;\r\n }\r\n }\r\n\r\n return parsedItem.data;\r\n}\r\n\r\n/**\r\n * Set an item in the localStorage\r\n * @param key The key\r\n * @param data The item data\r\n * @param expirationDate The expiration date\r\n */\r\nexport function setLocalStorageItem<T>(key: string, data: T, expirationDate?: Date): void {\r\n checkLocalStorageSupport();\r\n localStorage.setItem(key, JSON.stringify({ data, expirationDate }));\r\n}\r\n\r\n/**\r\n * Remove an item from the localStorage\r\n * @param key The key\r\n */\r\nexport function removeLocalStorageItem(key: string): void {\r\n checkLocalStorageSupport();\r\n localStorage.removeItem(key);\r\n}\r\n","import { isNullOrEmpty } from \"./string\";\n\n/**\n * Private helper function to check if a MIME type matches a main type pattern\n * @param mimeType The MIME type to check\n * @param mainType The main MIME type (e.g., \"image\", \"video\")\n * @returns true if the MIME type matches the pattern\n */\nfunction isMainMimeType(mimeType: string, mainType: string): boolean {\n const normalizedMimeType = mimeType.toLowerCase().trim();\n return normalizedMimeType.startsWith(`${mainType}/`) && normalizedMimeType.length > mainType.length + 1;\n}\n\n/**\n * Check if the MIME type represents an image\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for an image\n */\nexport function isImageMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n return isMainMimeType(mimeType!, \"image\");\n}\n\n/**\n * Check if the MIME type represents a PDF document\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for a PDF document\n */\nexport function isPdfMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n const normalizedMimeType = mimeType!.toLowerCase().trim();\n return normalizedMimeType === \"application/pdf\";\n}\n\n/**\n * Check if the MIME type represents a video\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for a video\n */\nexport function isVideoMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n return isMainMimeType(mimeType!, \"video\");\n}\n\n/**\n * Check if the MIME type represents an audio file\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for an audio file\n */\nexport function isAudioMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n return isMainMimeType(mimeType!, \"audio\");\n}\n\n/**\n * Check if the MIME type represents a text file\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for a text file\n */\nexport function isTextMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n return isMainMimeType(mimeType!, \"text\");\n}\n\n/**\n * Check if the MIME type represents an application file\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for an application file\n */\nexport function isApplicationMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n return isMainMimeType(mimeType!, \"application\");\n}\n","/**\r\n * Check whether the provided parameter is of type `object` but not `null`, an `array`, a `regexp`, nor a `date`\r\n * @param obj The object\r\n * @returns A boolean indicating whether the parameter is an object\r\n */\r\nexport const isObject = (obj: object): boolean =>\r\n typeof obj === \"object\" && obj !== null && !Array.isArray(obj) && !(obj instanceof RegExp) && !(obj instanceof Date);\r\n\r\n/**\r\n * Convert null properties to undefined\r\n * @param obj The object\r\n */\r\nexport const convertNullToUndefined = (obj: object | object[]): void => {\r\n if (Array.isArray(obj)) {\r\n for (const item of obj as unknown as object[]) {\r\n if (item === null) {\r\n obj[obj.indexOf(item)] = undefined;\r\n } else if (isObject(item)) {\r\n convertNullToUndefined(item);\r\n }\r\n }\r\n } else if (!isObject(obj)) {\r\n return;\r\n }\r\n\r\n for (const key of Object.keys(obj)) {\r\n const value = obj[key as keyof typeof obj];\r\n if (value === null) {\r\n delete obj[key as keyof typeof obj];\r\n } else if (isObject(value) || Array.isArray(value)) {\r\n convertNullToUndefined(value);\r\n }\r\n }\r\n};\r\n","import { isNullOrWhitespace } from \"./string\";\n\n/**\n * Checks if the provided string is a valid swiss IBAN number\n * @param ibanNumber The provided IBAN number to check\n * Must be in one of the following formats:\n * - \"CHXX XXXX XXXX XXXX XXXX X\" with whitespaces\n * - \"CHXXXXXXXXXXXXXXXXXXX\" without whitespaces\n * @returns The result of the IBAN number check\n */\nexport function isValidSwissIbanNumber(ibanNumber: string): boolean {\n // 1. Reject null, undefined or whitespace-only strings\n if (isNullOrWhitespace(ibanNumber)) {\n return false;\n }\n\n // 2. Define allowed strict formats\n // - with spaces: \"CHXX XXXX XXXX XXXX XXXX X\"\n const compactIbanNumberWithWhiteSpaces = new RegExp(/^CH[0-9]{2} [0-9]{4} [0-9][A-Z0-9]{3} [A-Z0-9]{4} [A-Z0-9]{4} [A-Z0-9]$/);\n // - without spaces: \"CHXXXXXXXXXXXXXXXXXXX\"\n const compactIbanNumberWithoutWhiteSpaces = new RegExp(/^CH[0-9]{7}[A-Z0-9]{12}$/);\n\n // 3. Check if the input matches one of the allowed formats\n if (!(compactIbanNumberWithWhiteSpaces.test(ibanNumber) || compactIbanNumberWithoutWhiteSpaces.test(ibanNumber))) {\n return false;\n }\n\n // 4. Remove all spaces to get a compact IBAN string\n const compactIbanNumber = ibanNumber.replaceAll(\" \", \"\");\n\n // 5. Rearrange IBAN for checksum calculation\n // - move first 4 characters (CH + 2 check digits) to the end\n const rearrangedIban = compactIbanNumber.slice(4) + compactIbanNumber.slice(0, 4);\n\n // 6. Replace letters with numbers (A=10, B=11, ..., Z=35)\n const numericStr = rearrangedIban.replaceAll(/[A-Z]/g, (ch) => (ch.codePointAt(0)! - 55).toString());\n\n // 7. Perform modulo 97 calculation to validate IBAN\n let restOfCalculation = 0;\n for (const digit of numericStr) {\n restOfCalculation = (restOfCalculation * 10 + Number(digit)) % 97;\n }\n\n // 8. IBAN is valid only if the remainder equals 1\n return restOfCalculation === 1;\n}\n\n/**\n * Validation of a social insurance number with checking the checksum\n * Validation according to https://www.sozialversicherungsnummer.ch/aufbau-neu.htm\n * @param socialInsuranceNumber The social insurance number to check\n * Must be in one of the following formats:\n * - \"756.XXXX.XXXX.XX\" with dots as separators\n * - \"756XXXXXXXXXX\" with digits only\n * @returns The result if the social insurance number is valid or not\n */\nexport function isValidSwissSocialInsuranceNumber(socialInsuranceNumber: string): boolean {\n // 1. Check if the input is empty or only a whitespace\n if (isNullOrWhitespace(socialInsuranceNumber)) {\n return false;\n }\n\n /**\n * 2. Check if the input matches one of the accepted formats:\n * - With dots: 756.XXXX.XXXX.XX\n * - Without dots: 756XXXXXXXXXX\n */\n const socialInsuranceNumberWithDots = new RegExp(/^756\\.\\d{4}\\.\\d{4}\\.\\d{2}$/);\n const socialInsuranceNumberWithoutDots = new RegExp(/^756\\d{10}$/);\n\n if (!socialInsuranceNumberWithDots.test(socialInsuranceNumber) && !socialInsuranceNumberWithoutDots.test(socialInsuranceNumber)) {\n return false;\n }\n\n // 3. Remove all dots → get a string of 13 digits\n const compactNumber = socialInsuranceNumber.replaceAll(\".\", \"\");\n\n /**\n * 4. Separate digits for checksum calculation\n * - first 12 digits: used to calculate checksum\n * - last digit: actual check digit\n */\n const digits = compactNumber.slice(0, -1);\n const reversedDigits = [...digits].reverse().join(\"\");\n const reversedDigitsArray = [...reversedDigits];\n\n /*\n * 5. Calculate weighted sum for checksum\n * - Even positions (after reversing) ×3\n * - Odd positions ×1\n */\n let sum = 0;\n for (const [i, element] of reversedDigitsArray.entries()) {\n sum += i % 2 === 0 ? Number(element) * 3 : Number(element) * 1;\n }\n\n /*\n * 6. Calculate expected check digit\n * - Check digit = value to reach next multiple of 10\n */\n const checksum = (10 - (sum % 10)) % 10;\n const checknumber = Number.parseInt(compactNumber.slice(-1));\n\n /*\n * 7. Compare calculated check digit with actual last digit\n * - If equal → valid AHV number\n */\n return checksum === checknumber;\n}\n\n/**\n * Attempts to parse and validate a Swiss IBAN.\n * @param unformattedIbanNumber - The unformatted IBAN as a string\n * @returns The result object with the following properties:\n * @property {boolean} isValid - Indicates whether the IBAN is valid or not\n * @property {string} iban - The cleaned IBAN, only present if valid\n * @property {string} ibanFormatted - The formatted IBAN, only present if valid\n */\nexport function tryParseSwissIbanNumber(unformattedIbanNumber?: string): {\n /**\n * Indicates whether the IBAN is valid or not\n */\n isValid: boolean;\n /**\n * The cleaned IBAN, only present if valid\n */\n iban?: string;\n /**\n * The formatted IBAN, only present if valid\n */\n ibanFormatted?: string;\n} {\n if (isNullOrWhitespace(unformattedIbanNumber)) {\n return { isValid: false };\n }\n\n const iban = unformattedIbanNumber!.replaceAll(/[^A-Z0-9]/gi, \"\").toUpperCase();\n const isValid = isValidSwissIbanNumber(iban);\n\n return {\n isValid: isValid,\n iban: isValid ? iban : undefined,\n ibanFormatted: isValid ? iban.match(/.{1,4}/g)?.join(\" \") : undefined,\n };\n}\n\n/**\n * Attempts to parse and validate a Swiss social insurance number.\n * @param unformattedInsuranceNumber - The unformatted Swiss social insurance number\n * @returns The result object with the following properties:\n * @property {boolean} isValid - Indicates whether the Swiss social insurance number is valid or not\n * @property {string} swissSocialInsuranceNumber - The cleaned Swiss social insurance number, only present if valid\n * @property {string} swissSocialInsuranceNumberFormatted - The formatted Swiss social insurance number, only present if valid\n */\nexport function tryParseSwissSocialInsuranceNumber(unformattedInsuranceNumber?: string): {\n /**\n * Indicates whether the Swiss social insurance number is valid or not\n */\n isValid: boolean;\n /**\n * The cleaned Swiss social insurance number, only present if valid\n */\n swissSocialInsuranceNumber?: string;\n /**\n * The formatted Swiss social insurance number, only present if valid\n */\n swissSocialInsuranceNumberFormatted?: string;\n} {\n if (isNullOrWhitespace(unformattedInsuranceNumber)) {\n return { isValid: false };\n }\n\n const insuranceNumber = unformattedInsuranceNumber!.replaceAll(/\\D/g, \"\");\n const isValid = isValidSwissSocialInsuranceNumber(insuranceNumber);\n\n return {\n isValid: isValid,\n swissSocialInsuranceNumber: isValid ? insuranceNumber : undefined,\n swissSocialInsuranceNumberFormatted: isValid ? insuranceNumber.replace(/^(\\d{3})(\\d{4})(\\d{4})(\\d{2})$/, \"$1.$2.$3.$4\") : undefined,\n };\n}\n","import { getEnumNameFromValue, StandardEnum } from \"./enum\";\r\nimport { isNullOrWhitespace } from \"./string\";\r\n\r\n/**\r\n * Methods to help caching data of any type.\r\n * Data is put in containers and may be identified by a string key.\r\n * Data can be saved, retrieved and reset.\r\n * Based on Neolution.Abstractions.Caching.CacheProvider<TEnum>\r\n * Ref: https://github.com/neolution-ch/Neolution.Abstractions/blob/main/Neolution.Abstractions/Caching/CacheProvider.cs\r\n */\r\nexport class CacheProvider<TEnum> {\r\n /**\r\n * The enum variable\r\n */\r\n private readonly enumVariable: StandardEnum<TEnum>;\r\n\r\n /**\r\n * The name of the cache\r\n */\r\n private readonly cacheName: string;\r\n\r\n /**\r\n * The cache\r\n */\r\n private readonly cache = new Map<string, object>();\r\n\r\n /**\r\n * Initializes a new instance of the CacheProvider<TEnum> class\r\n * @param enumVariable The enum variable\r\n * @param cacheName The name of the cache\r\n */\r\n constructor(enumVariable: StandardEnum<TEnum>, cacheName: string) {\r\n this.enumVariable = enumVariable;\r\n this.cacheName = cacheName;\r\n }\r\n\r\n /**\r\n * Creates the cache key\r\n * @param container The container\r\n * @param key The key\r\n * @returns The cache key\r\n */\r\n private createCacheKey(container: TEnum, key?: string): string {\r\n let containerName = getEnumNameFromValue(this.enumVariable, container);\r\n\r\n if (key && !isNullOrWhitespace(key)) {\r\n containerName = `${containerName}_${key}`;\r\n }\r\n\r\n return `${this.cacheName}:${containerName}`;\r\n }\r\n\r\n /**\r\n * Gets cached data from the specified container\r\n * @param container The container\r\n * @param key The key\r\n * @returns The data from cache\r\n */\r\n getObject<T>(container: TEnum, key?: string): T | undefined {\r\n return this.cache.get(this.createCacheKey(container, key)) as T;\r\n }\r\n\r\n /**\r\n * Sets cached data identified by a key in the specified container\r\n * @param container The container\r\n * @param key The key\r\n * @param cacheObject The cache object\r\n */\r\n setObject<T>(container: TEnum, key: string | undefined, cacheObject: T): void {\r\n this.cache.set(this.createCacheKey(container, key), cacheObject as object);\r\n }\r\n\r\n /**\r\n * Resets cached data identified by a key of the specified container\r\n * @param container The container\r\n * @param key The key\r\n */\r\n reset(container: TEnum, key?: string): void {\r\n this.cache.delete(this.createCacheKey(container, key));\r\n }\r\n}\r\n","/**\r\n * Returns a number whose value is limited to the given range\r\n * @param value The initial value\r\n * @param min The lower boundary\r\n * @param max The upper boundary\r\n * @returns A number in the range (min, max)\r\n */\r\nexport function clamp(value: number, min: number, max: number): number {\r\n if (min > max) {\r\n throw new Error(`'${min}' cannot be greater than '${max}'.`);\r\n }\r\n return Math.min(Math.max(value, min), max);\r\n}\r\n\r\n/**\r\n * Round a number with the specified precision\r\n * @param value The number to round\r\n * @param precision The desired precision\r\n * @returns The number rounded with the specified precision\r\n */\r\nexport function roundPrecision(value: number, precision: number): number {\r\n const multiplier = Math.pow(10, precision);\r\n return Math.round(value * multiplier) / multiplier;\r\n}\r\n","import { isNullOrEmpty } from \"./string\";\r\n\r\n/**\r\n * Converts a string to a boolean\r\n * @param value The string to convert\r\n * @returns The parsed boolean\r\n */\r\nexport function parseBool(value?: string): boolean {\r\n // Similar to C# implementation that trims also null characters\r\n // https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Boolean.cs#L277\r\n return !isNullOrEmpty(value) && value?.replace(/[\\s\\0]/g, \"\").toLowerCase() === \"true\";\r\n}\r\n"],"names":["isNullOrEmpty","value","length","isNullOrWhitespace","trim","trimStart","haystack","needle","offset","indexOf","slice","trimEnd","idx","lastIndexOf","getEnumNameFromValue","enumVariable","enumValue","result","undefined","isEnumString","Object","keys","values","getEnumValueFromName","enumName","key","test","dateIsValid","date","isDate","isValid","emptyGuid","uuid","NIL","checkLocalStorageSupport","localStorage","TypeError","isMainMimeType","mimeType","mainType","normalizedMimeType","toLowerCase","startsWith","isObject","obj","Array","isArray","RegExp","Date","convertNullToUndefined","item","isValidSwissIbanNumber","ibanNumber","compactIbanNumberWithWhiteSpaces","compactIbanNumberWithoutWhiteSpaces","compactIbanNumber","replaceAll","numericStr","ch","codePointAt","toString","restOfCalculation","digit","Number","isValidSwissSocialInsuranceNumber","socialInsuranceNumber","socialInsuranceNumberWithDots","socialInsuranceNumberWithoutDots","compactNumber","reversedDigitsArray","reverse","join","sum","i","element","entries","parseInt","cacheName","cache","Map","constructor","this","createCacheKey","container","containerName","getObject","get","setObject","cacheObject","set","reset","delete","amount","addQuartersInternal","NaN","charAt","toUpperCase","min","max","Error","Math","from","to","abs","differenceInCalendarDays","isFirstDayOfMonth","isLastDayOfMonth","isLeapYear","isWeekend","getTime","getTimezoneOffset","endOfDay","names","map","getFullYear","lastDayOfYear","getItem","parsedItem","JSON","parse","expirationDate","revivedExpirationDate","removeItem","data","addBusinessDays","getQuarterInternal","startOfDay","str","v4","replace","isNaN","precision","multiplier","pow","round","setItem","stringify","removeEmptyEntries","trimEntries","splitted","split","x","filter","line","maxLength","suffix","unformattedIbanNumber","iban","ibanFormatted","match","unformattedInsuranceNumber","insuranceNumber","swissSocialInsuranceNumber","swissSocialInsuranceNumberFormatted"],"mappings":"+VAKM,SAAUA,EAAcC,GAC5B,OAAKA,GAA0B,iBAAVA,GAIG,IAAjBA,EAAMC,MACf,CAOM,SAAUC,EAAmBF,GACjC,OAAOD,EAAcC,IAA8C,IAAnCA,EAAiBG,OAAOF,MAC1D,CAqDgB,SAAAG,EAAUC,EAAkBC,GAC1C,GAAIP,EAAcM,IAAaN,EAAcO,GAC3C,OAAOD,EAGT,IAAIE,EAAS,EAEb,KAAOF,EAASG,QAAQF,EAAQC,KAAYA,GAC1CA,GAAkBD,EAAOL,OAE3B,OAAOI,EAASI,MAAMF,EACxB,CAQgB,SAAAG,EAAQL,EAAkBC,GACxC,GAAIP,EAAcM,IAAaN,EAAcO,GAC3C,OAAOD,EAGT,IAAIE,EAASF,EAASJ,OACpBU,GAAO,EAET,KACEA,EAAMN,EAASO,YAAYN,EAAQC,EAAS,IAC/B,IAATI,GAAcA,EAAML,EAAOL,SAAWM,GAF/B,CAKX,GAAY,IAARI,EACF,MAAO,GAETJ,EAASI,CACV,CAED,OAAON,EAASI,MAAM,EAAGF,EAC3B,CClGgB,SAAAM,EAAwBC,EAA+BC,GACrE,IAAIC,EAASF,EAAaC,GAM1B,YAJeE,IAAXD,GAAwBE,EAAaJ,KACvCE,EAASG,OAAOC,KAAKN,GAAcK,OAAOE,OAAOP,GAAcN,QAAQ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mBC,EAAS,IAC9E,OAAKhJ,GAASE,EAAmBF,IAI7BA,EAAMC,QAAU8I,EAHX/I,EAOF,GAAGA,EAAMS,MAAM,EAAGsI,KAAaC,GACxC,kCOqDM,SAAkCC,GActC,GAAI/I,EAAmB+I,GACrB,MAAO,CAAEpH,SAAS,GAGpB,MAAMqH,EAAOD,EAAuB1F,WAAW,cAAe,IAAIwC,cAC5DlE,EAAUqB,EAAuBgG,GAEvC,MAAO,CACLrH,QAASA,EACTqH,KAAMrH,EAAUqH,OAAOjI,EACvBkI,cAAetH,EAAUqH,EAAKE,MAAM,YAAY9E,KAAK,UAAOrD,EAEhE,6CAUM,SAA6CoI,GAcjD,GAAInJ,EAAmBmJ,GACrB,MAAO,CAAExH,SAAS,GAGpB,MAAMyH,EAAkBD,EAA4B9F,WAAW,MAAO,IAChE1B,EAAUkC,EAAkCuF,GAElD,MAAO,CACLzH,QAASA,EACT0H,2BAA4B1H,EAAUyH,OAAkBrI,EACxDuI,oCAAqC3H,EAAUyH,EAAgBtB,QAAQ,iCAAkC,oBAAiB/G,EAE9H,uBP5IM,SAAuBjB,GAC3B,OAAKA,GAASE,EAAmBF,GACxBA,EAGFA,EAAM8F,OAAO,GAAGtD,cAAgBxC,EAAMS,MAAM,EACrD"}
|
package/dist/index.modern.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/lib/string.ts","../src/lib/boolean.ts","../src/lib/enum.ts","../src/lib/cacheProvider.ts","../src/lib/date.ts","../src/lib/guid.ts","../src/lib/localStorage.ts","../src/lib/mimeType.ts","../src/lib/number.ts","../src/lib/object.ts","../src/lib/swissStandards.ts"],"sourcesContent":["/**\r\n * Indicates whether a specified string is null/undefined or empty\r\n * @param value The string to test\r\n * @returns true if the value parameter is null/undefined or empty\r\n */\r\nexport function isNullOrEmpty(value?: string): boolean {\r\n if (!value || typeof value !== \"string\") {\r\n return true;\r\n }\r\n\r\n return value.length === 0;\r\n}\r\n\r\n/**\r\n * Indicates whether a specified string is null/undefined, empty, or consists only of white-space characters\r\n * @param value The string to test\r\n * @returns true if the value parameter is null/undefined, Empty, or if value consists exclusively of white-space characters\r\n */\r\nexport function isNullOrWhitespace(value?: string): boolean {\r\n return isNullOrEmpty(value) || (value as string).trim().length === 0;\r\n}\r\n\r\n/**\r\n * Capitalize the string\r\n * @param value The string to capitalize\r\n * @returns The capitalized string\r\n */\r\nexport function capitalize(value?: string): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n return value.charAt(0).toUpperCase() + value.slice(1);\r\n}\r\n\r\n/**\r\n * Uncapitalize the string\r\n * @param value The string to uncapitalize\r\n * @returns The uncapitalized string\r\n */\r\nexport function uncapitalize(value?: string): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n return value.charAt(0).toLowerCase() + value.slice(1);\r\n}\r\n\r\n/**\r\n * Truncates a string to a maximum length, adding a suffix if truncated\r\n * @param value The string to truncate\r\n * @param maxLength The maximum length of the resulting string\r\n * @param suffix The suffix to append if truncated (default: \"\")\r\n * @returns The truncated string\r\n */\r\nexport function truncate(value: string | undefined, maxLength: number, suffix = \"\"): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n if (value.length <= maxLength) {\r\n return value;\r\n }\r\n\r\n return `${value.slice(0, maxLength)}${suffix}`;\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the start of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the left side\r\n */\r\nexport function trimStart(haystack: string, needle: string): string {\r\n if (isNullOrEmpty(haystack) || isNullOrEmpty(needle)) {\r\n return haystack;\r\n }\r\n\r\n let offset = 0;\r\n\r\n while (haystack.indexOf(needle, offset) === offset) {\r\n offset = offset + needle.length;\r\n }\r\n return haystack.slice(offset);\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the end of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the right side\r\n */\r\nexport function trimEnd(haystack: string, needle: string): string {\r\n if (isNullOrEmpty(haystack) || isNullOrEmpty(needle)) {\r\n return haystack;\r\n }\r\n\r\n let offset = haystack.length,\r\n idx = -1;\r\n\r\n while (true) {\r\n idx = haystack.lastIndexOf(needle, offset - 1);\r\n if (idx === -1 || idx + needle.length !== offset) {\r\n break;\r\n }\r\n if (idx === 0) {\r\n return \"\";\r\n }\r\n offset = idx;\r\n }\r\n\r\n return haystack.slice(0, offset);\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the start and the end of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the right and left side\r\n */\r\nexport function trim(haystack: string, needle: string): string {\r\n const trimmed = trimStart(haystack, needle);\r\n return trimEnd(trimmed, needle);\r\n}\r\n\r\n/**\r\n * Splits the string at line breaks\r\n * @param str the string to split\r\n * @param removeEmptyEntries the option to remove empty entries\r\n * @param trimEntries the option to trim the entries\r\n * @returns the individual lines as an array\r\n */\r\nexport function splitLines(str: string, removeEmptyEntries: boolean = false, trimEntries: boolean = false): string[] {\r\n if (isNullOrEmpty(str)) {\r\n return [];\r\n }\r\n\r\n let splitted = str.split(/\\r\\n|\\r|\\n/);\r\n\r\n if (trimEntries) {\r\n splitted = splitted.map((x) => x.trim());\r\n }\r\n\r\n if (removeEmptyEntries) {\r\n splitted = splitted.filter((line) => line.length > 0);\r\n }\r\n\r\n return splitted;\r\n}\r\n","import { isNullOrEmpty } from \"./string\";\r\n\r\n/**\r\n * Converts a string to a boolean\r\n * @param value The string to convert\r\n * @returns The parsed boolean\r\n */\r\nexport function parseBool(value?: string): boolean {\r\n // Similar to C# implementation that trims also null characters\r\n // https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Boolean.cs#L277\r\n return !isNullOrEmpty(value) && value?.replace(/[\\s\\0]/g, \"\").toLowerCase() === \"true\";\r\n}\r\n","/**\r\n * The standard enum type\r\n */\r\nexport type StandardEnum<T> = {\r\n [id: string]: T | string;\r\n [nu: number]: string;\r\n};\r\n\r\n/**\r\n * Returns the name of an enum from its value\r\n * @param enumVariable The enum for which you want to get the name\r\n * @param enumValue The value of the enum for which you want to get the name\r\n * @returns A string containing the name of the enum\r\n */\r\nexport function getEnumNameFromValue<T>(enumVariable: StandardEnum<T>, enumValue: T): string {\r\n let result = enumVariable[enumValue as keyof StandardEnum<T>] as string;\r\n\r\n if (result === undefined && isEnumString(enumVariable)) {\r\n result = Object.keys(enumVariable)[Object.values(enumVariable).indexOf(enumValue)];\r\n }\r\n\r\n return result;\r\n}\r\n\r\n/**\r\n * Returns the value of an enum from its name\r\n * @param enumVariable The enum for which you want to get the value\r\n * @param enumName The name of the enum for which you want to get the value\r\n * @returns A string containing the value of the enum\r\n */\r\nexport function getEnumValueFromName<T>(enumVariable: StandardEnum<T>, enumName: string): T {\r\n return enumVariable[enumName as keyof StandardEnum<T>] as T;\r\n}\r\n\r\n/**\r\n * Returns all the names of an enum\r\n * @param enumVariable The enum for which you want to get the names\r\n * @returns A string array containing the names of the enum\r\n */\r\nexport function getEnumNames<T>(enumVariable: StandardEnum<T>) {\r\n const names = Object.values(enumVariable);\r\n\r\n // If enum is with values integer, object.values returns a list of [names, values].\r\n return isEnumString(enumVariable) ? Object.keys(enumVariable) : names.slice(0, names.length / 2);\r\n}\r\n\r\n/**\r\n * Returns all the values of an enum\r\n * @param enumVariable The enum for which you want to get the values\r\n * @returns A string or number array containing the values of the enum\r\n */\r\nexport function getEnumValues<T>(enumVariable: StandardEnum<T>): T[] {\r\n const keys = Object.keys(enumVariable);\r\n\r\n // If enum is with values integer, object.keys returns a list of [values, names].\r\n return (\r\n isEnumString(enumVariable) ? Object.values(enumVariable) : keys.slice(0, keys.length / 2).map((value) => Number.parseInt(value))\r\n ) as T[];\r\n}\r\n\r\n/**\r\n * Parses a string to an enum value\r\n * @param enumVariable The enum for which you want to get the values\r\n * @param value The string to parse\r\n * @returns The enum value corresponding to the string, or undefined if not found\r\n */\r\nexport function parseEnum<T>(enumVariable: StandardEnum<T>, value: string): T | undefined {\r\n if (!isEnumString(enumVariable) && Number.isNaN(Number(value))) {\r\n return undefined;\r\n }\r\n\r\n return getEnumValueFromName(enumVariable, getEnumNameFromValue(enumVariable, value as T));\r\n}\r\n\r\n/**\r\n * Returns if it's a enum with string value\r\n * @param enumVariable The enum\r\n * @returns A bool\r\n */\r\nfunction isEnumString<T>(enumVariable: StandardEnum<T>) {\r\n for (const key in enumVariable) {\r\n return !/^\\d+$/.test(key);\r\n }\r\n\r\n return false;\r\n}\r\n","import { getEnumNameFromValue, StandardEnum } from \"./enum\";\r\nimport { isNullOrWhitespace } from \"./string\";\r\n\r\n/**\r\n * Methods to help caching data of any type.\r\n * Data is put in containers and may be identified by a string key.\r\n * Data can be saved, retrieved and reset.\r\n * Based on Neolution.Abstractions.Caching.CacheProvider<TEnum>\r\n * Ref: https://github.com/neolution-ch/Neolution.Abstractions/blob/main/Neolution.Abstractions/Caching/CacheProvider.cs\r\n */\r\nexport class CacheProvider<TEnum> {\r\n /**\r\n * The enum variable\r\n */\r\n private readonly enumVariable: StandardEnum<TEnum>;\r\n\r\n /**\r\n * The name of the cache\r\n */\r\n private readonly cacheName: string;\r\n\r\n /**\r\n * The cache\r\n */\r\n private readonly cache = new Map<string, object>();\r\n\r\n /**\r\n * Initializes a new instance of the CacheProvider<TEnum> class\r\n * @param enumVariable The enum variable\r\n * @param cacheName The name of the cache\r\n */\r\n constructor(enumVariable: StandardEnum<TEnum>, cacheName: string) {\r\n this.enumVariable = enumVariable;\r\n this.cacheName = cacheName;\r\n }\r\n\r\n /**\r\n * Creates the cache key\r\n * @param container The container\r\n * @param key The key\r\n * @returns The cache key\r\n */\r\n private createCacheKey(container: TEnum, key?: string): string {\r\n let containerName = getEnumNameFromValue(this.enumVariable, container);\r\n\r\n if (key && !isNullOrWhitespace(key)) {\r\n containerName = `${containerName}_${key}`;\r\n }\r\n\r\n return `${this.cacheName}:${containerName}`;\r\n }\r\n\r\n /**\r\n * Gets cached data from the specified container\r\n * @param container The container\r\n * @param key The key\r\n * @returns The data from cache\r\n */\r\n getObject<T>(container: TEnum, key?: string): T | undefined {\r\n return this.cache.get(this.createCacheKey(container, key)) as T;\r\n }\r\n\r\n /**\r\n * Sets cached data identified by a key in the specified container\r\n * @param container The container\r\n * @param key The key\r\n * @param cacheObject The cache object\r\n */\r\n setObject<T>(container: TEnum, key: string | undefined, cacheObject: T): void {\r\n this.cache.set(this.createCacheKey(container, key), cacheObject as object);\r\n }\r\n\r\n /**\r\n * Resets cached data identified by a key of the specified container\r\n * @param container The container\r\n * @param key The key\r\n */\r\n reset(container: TEnum, key?: string): void {\r\n this.cache.delete(this.createCacheKey(container, key));\r\n }\r\n}\r\n","import {\r\n isDate,\r\n isValid,\r\n isFirstDayOfMonth,\r\n isLastDayOfMonth,\r\n isLeapYear,\r\n isWeekend,\r\n differenceInCalendarDays,\r\n addBusinessDays,\r\n startOfDay,\r\n endOfDay,\r\n lastDayOfYear,\r\n getQuarter as getQuarterInternal,\r\n addQuarters as addQuartersInternal,\r\n} from \"date-fns\";\r\n\r\n/**\r\n * Check whether the date is valid\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is valid\r\n */\r\nexport function dateIsValid(date: Date): boolean {\r\n return isDate(date) && isValid(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is the first day of the month\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is the first day of the month\r\n */\r\nexport function dateIsFirstDayOfMonth(date: Date): boolean {\r\n return dateIsValid(date) && isFirstDayOfMonth(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is the last day of the month\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is the last day of the month\r\n */\r\nexport function dateIsLastDayOfMonth(date: Date): boolean {\r\n return dateIsValid(date) && isLastDayOfMonth(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is a leap year\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is a leap year\r\n */\r\nexport function dateIsLeapYear(date: Date): boolean {\r\n return dateIsValid(date) && isLeapYear(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is a weekend\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is a weekend\r\n */\r\nexport function dateIsWeekend(date: Date): boolean {\r\n return dateIsValid(date) && isWeekend(date);\r\n}\r\n\r\n/**\r\n * Calculate the difference in days between two dates\r\n * The order is not relevant hence the result is always positive\r\n * @param from The start date\r\n * @param to The end date\r\n * @returns The difference in days between two dates\r\n */\r\nexport function dateDifferenceInDays(from: Date, to: Date): number {\r\n return dateIsValid(from) && dateIsValid(to) ? Math.abs(differenceInCalendarDays(from, to)) : Number.NaN;\r\n}\r\n\r\n/**\r\n * Get the next business date\r\n * @param date The date\r\n * @returns The next business date\r\n */\r\nexport function getNextBusinessDate(date: Date): Date {\r\n return dateIsValid(date) ? addBusinessDays(date, 1) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the start of a day for the given date\r\n * @param date The date\r\n * @returns The start of a day date\r\n */\r\nexport function getStartOfDay(date: Date): Date {\r\n return dateIsValid(date) ? startOfDay(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the end of a day for the given date\r\n * @param date The date\r\n * @returns The end of a day date\r\n */\r\nexport function getEndOfDay(date: Date): Date {\r\n return dateIsValid(date) ? endOfDay(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the first day of a year for the given date\r\n * @param date The date\r\n * @returns The first day of the date year\r\n */\r\nexport function getFirstDayOfYear(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getFullYear(), 0, 1) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the last day of a year for the given date\r\n * @param date The date\r\n * @returns The last day of the date year\r\n */\r\nexport function getLastDayOfYear(date: Date): Date {\r\n return dateIsValid(date) ? lastDayOfYear(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the year quarter for the given date\r\n * @param date The date\r\n * @returns The year quarter\r\n */\r\nexport function getQuarter(date: Date): number {\r\n return dateIsValid(date) ? getQuarterInternal(date) : Number.NaN;\r\n}\r\n\r\n/**\r\n * Shifts a date by a given number of quarters.\r\n * @param date The date\r\n * @param amount Number of quarters to shift by (negative values shift the date backwards)\r\n * @returns A new Date shifted by the specified number of quarters\r\n */\r\nexport function addQuarters(date: Date, amount: number): Date {\r\n return dateIsValid(date) ? addQuartersInternal(date, amount) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the date removing the time-zone offset\r\n * @param date The date\r\n * @returns the given date removing the time-zone offset\r\n */\r\nexport function getDateWithoutTimeZone(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getTime() - date.getTimezoneOffset() * 60_000) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the date adding the time-zone offset\r\n * @param date The date\r\n * @returns the given date adding the time-zone offset\r\n */\r\nexport function getDateAddTimeZone(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getTime() + date.getTimezoneOffset() * 60_000) : new Date(Number.NaN);\r\n}\r\n","import * as uuid from \"uuid\";\r\n\r\n/**\r\n * Create a new Guid (version 4 UUID)\r\n * @returns A new Guid\r\n */\r\nexport function newGuid() {\r\n return uuid.v4();\r\n}\r\n\r\n/**\r\n * Check whether a string it is a valid Guid\r\n * @param str The string to test whether it is a valid Guid\r\n * @returns A value indicating whether the string is a valid Guid\r\n */\r\nexport function isValidGuid(str: string) {\r\n const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\r\n return typeof str === \"string\" && regex.test(str);\r\n}\r\n\r\n/**\r\n * The empty Guid (an identifier containing all zeros)\r\n */\r\nexport const emptyGuid: string = uuid.NIL;\r\n","import { dateIsValid } from \"./date\";\r\n\r\n/**\r\n * The localStorage item\r\n */\r\ninterface LocalStorageItem<T> {\r\n /**\r\n * The data\r\n */\r\n data: T;\r\n\r\n /**\r\n * The expiration date\r\n */\r\n expirationDate?: Date;\r\n}\r\n\r\n/**\r\n * Check if the localStorage is supported\r\n */\r\nconst checkLocalStorageSupport = () => {\r\n if (typeof localStorage === \"undefined\") {\r\n throw new TypeError(\"localStorage not supported\");\r\n }\r\n};\r\n\r\n/**\r\n * Get an item from the localStorage\r\n * @param key The key\r\n * @returns The item\r\n */\r\nexport function getLocalStorageItem<T>(key: string): T | undefined {\r\n checkLocalStorageSupport();\r\n\r\n const item = localStorage.getItem(key);\r\n if (!item) {\r\n return undefined;\r\n }\r\n\r\n const parsedItem = JSON.parse(item) as LocalStorageItem<T>;\r\n\r\n if (parsedItem.expirationDate) {\r\n const revivedExpirationDate = new Date(parsedItem.expirationDate);\r\n if (dateIsValid(revivedExpirationDate) && revivedExpirationDate < new Date()) {\r\n localStorage.removeItem(key);\r\n return undefined;\r\n }\r\n }\r\n\r\n return parsedItem.data;\r\n}\r\n\r\n/**\r\n * Set an item in the localStorage\r\n * @param key The key\r\n * @param data The item data\r\n * @param expirationDate The expiration date\r\n */\r\nexport function setLocalStorageItem<T>(key: string, data: T, expirationDate?: Date): void {\r\n checkLocalStorageSupport();\r\n localStorage.setItem(key, JSON.stringify({ data, expirationDate }));\r\n}\r\n\r\n/**\r\n * Remove an item from the localStorage\r\n * @param key The key\r\n */\r\nexport function removeLocalStorageItem(key: string): void {\r\n checkLocalStorageSupport();\r\n localStorage.removeItem(key);\r\n}\r\n","import { isNullOrEmpty } from \"./string\";\r\n\r\n/**\r\n * Private helper function to check if a MIME type matches a main type pattern\r\n * @param mimeType The MIME type to check\r\n * @param mainType The main MIME type (e.g., \"image\", \"video\")\r\n * @returns true if the MIME type matches the pattern\r\n */\r\nfunction isMainMimeType(mimeType: string, mainType: string): boolean {\r\n const normalizedMimeType = mimeType.toLowerCase().trim();\r\n return normalizedMimeType.startsWith(`${mainType}/`) && normalizedMimeType.length > mainType.length + 1;\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents an image\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for an image\r\n */\r\nexport function isImageMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n return isMainMimeType(mimeType!, \"image\");\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents a PDF document\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for a PDF document\r\n */\r\nexport function isPdfMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n const normalizedMimeType = mimeType!.toLowerCase().trim();\r\n return normalizedMimeType === \"application/pdf\";\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents a video\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for a video\r\n */\r\nexport function isVideoMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n return isMainMimeType(mimeType!, \"video\");\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents an audio file\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for an audio file\r\n */\r\nexport function isAudioMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n return isMainMimeType(mimeType!, \"audio\");\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents a text file\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for a text file\r\n */\r\nexport function isTextMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n return isMainMimeType(mimeType!, \"text\");\r\n}\r\n\r\n/**\r\n * Check if the MIME type represents an application file\r\n * @param mimeType The MIME type to check\r\n * @returns true if the MIME type is for an application file\r\n */\r\nexport function isApplicationMimeType(mimeType?: string): boolean {\r\n if (isNullOrEmpty(mimeType)) {\r\n return false;\r\n }\r\n\r\n return isMainMimeType(mimeType!, \"application\");\r\n}\r\n","/**\r\n * Returns a number whose value is limited to the given range\r\n * @param value The initial value\r\n * @param min The lower boundary\r\n * @param max The upper boundary\r\n * @returns A number in the range (min, max)\r\n */\r\nexport function clamp(value: number, min: number, max: number): number {\r\n if (min > max) {\r\n throw new Error(`'${min}' cannot be greater than '${max}'.`);\r\n }\r\n return Math.min(Math.max(value, min), max);\r\n}\r\n\r\n/**\r\n * Round a number with the specified precision\r\n * @param value The number to round\r\n * @param precision The desired precision\r\n * @returns The number rounded with the specified precision\r\n */\r\nexport function roundPrecision(value: number, precision: number): number {\r\n const multiplier = Math.pow(10, precision);\r\n return Math.round(value * multiplier) / multiplier;\r\n}\r\n","/**\r\n * Check whether the provided parameter is of type `object` but not `null`, an `array`, a `regexp`, nor a `date`\r\n * @param obj The object\r\n * @returns A boolean indicating whether the parameter is an object\r\n */\r\nexport const isObject = (obj: object): boolean =>\r\n typeof obj === \"object\" && obj !== null && !Array.isArray(obj) && !(obj instanceof RegExp) && !(obj instanceof Date);\r\n\r\n/**\r\n * Convert null properties to undefined\r\n * @param obj The object\r\n */\r\nexport const convertNullToUndefined = (obj: object | object[]): void => {\r\n if (Array.isArray(obj)) {\r\n for (const item of obj as unknown as object[]) {\r\n if (item === null) {\r\n obj[obj.indexOf(item)] = undefined;\r\n } else if (isObject(item)) {\r\n convertNullToUndefined(item);\r\n }\r\n }\r\n } else if (!isObject(obj)) {\r\n return;\r\n }\r\n\r\n for (const key of Object.keys(obj)) {\r\n const value = obj[key as keyof typeof obj];\r\n if (value === null) {\r\n delete obj[key as keyof typeof obj];\r\n } else if (isObject(value) || Array.isArray(value)) {\r\n convertNullToUndefined(value);\r\n }\r\n }\r\n};\r\n","import { isNullOrWhitespace } from \"./string\";\r\n\r\n/**\r\n * Checks if the provided string is a valid swiss IBAN number\r\n * @param ibanNumber The provided IBAN number to check\r\n * Must be in one of the following formats:\r\n * - \"CHXX XXXX XXXX XXXX XXXX X\" with whitespaces\r\n * - \"CHXXXXXXXXXXXXXXXXXXX\" without whitespaces\r\n * @returns The result of the IBAN number check\r\n */\r\nexport function isValidSwissIbanNumber(ibanNumber: string): boolean {\r\n // 1. Reject null, undefined or whitespace-only strings\r\n if (isNullOrWhitespace(ibanNumber)) {\r\n return false;\r\n }\r\n\r\n // 2. Define allowed strict formats\r\n // - with spaces: \"CHXX XXXX XXXX XXXX XXXX X\"\r\n const compactIbanNumberWithWhiteSpaces = new RegExp(/^CH[0-9]{2} [0-9]{4} [0-9][A-Z0-9]{3} [A-Z0-9]{4} [A-Z0-9]{4} [A-Z0-9]$/);\r\n // - without spaces: \"CHXXXXXXXXXXXXXXXXXXX\"\r\n const compactIbanNumberWithoutWhiteSpaces = new RegExp(/^CH[0-9]{7}[A-Z0-9]{12}$/);\r\n\r\n // 3. Check if the input matches one of the allowed formats\r\n if (!(compactIbanNumberWithWhiteSpaces.test(ibanNumber) || compactIbanNumberWithoutWhiteSpaces.test(ibanNumber))) {\r\n return false;\r\n }\r\n\r\n // 4. Remove all spaces to get a compact IBAN string\r\n const compactIbanNumber = ibanNumber.replaceAll(\" \", \"\");\r\n\r\n // 5. Rearrange IBAN for checksum calculation\r\n // - move first 4 characters (CH + 2 check digits) to the end\r\n const rearrangedIban = compactIbanNumber.slice(4) + compactIbanNumber.slice(0, 4);\r\n\r\n // 6. Replace letters with numbers (A=10, B=11, ..., Z=35)\r\n const numericStr = rearrangedIban.replaceAll(/[A-Z]/g, (ch) => (ch.codePointAt(0)! - 55).toString());\r\n\r\n // 7. Perform modulo 97 calculation to validate IBAN\r\n let restOfCalculation = 0;\r\n for (const digit of numericStr) {\r\n restOfCalculation = (restOfCalculation * 10 + Number(digit)) % 97;\r\n }\r\n\r\n // 8. IBAN is valid only if the remainder equals 1\r\n return restOfCalculation === 1;\r\n}\r\n\r\n/**\r\n * Validation of a social insurance number with checking the checksum\r\n * Validation according to https://www.sozialversicherungsnummer.ch/aufbau-neu.htm\r\n * @param socialInsuranceNumber The social insurance number to check\r\n * Must be in one of the following formats:\r\n * - \"756.XXXX.XXXX.XX\" with dots as separators\r\n * - \"756XXXXXXXXXX\" with digits only\r\n * @returns The result if the social insurance number is valid or not\r\n */\r\nexport function isValidSwissSocialInsuranceNumber(socialInsuranceNumber: string): boolean {\r\n // 1. Check if the input is empty or only a whitespace\r\n if (isNullOrWhitespace(socialInsuranceNumber)) {\r\n return false;\r\n }\r\n\r\n /**\r\n * 2. Check if the input matches one of the accepted formats:\r\n * - With dots: 756.XXXX.XXXX.XX\r\n * - Without dots: 756XXXXXXXXXX\r\n */\r\n const socialInsuranceNumberWithDots = new RegExp(/^756\\.\\d{4}\\.\\d{4}\\.\\d{2}$/);\r\n const socialInsuranceNumberWithoutDots = new RegExp(/^756\\d{10}$/);\r\n\r\n if (!socialInsuranceNumberWithDots.test(socialInsuranceNumber) && !socialInsuranceNumberWithoutDots.test(socialInsuranceNumber)) {\r\n return false;\r\n }\r\n\r\n // 3. Remove all dots → get a string of 13 digits\r\n const compactNumber = socialInsuranceNumber.replaceAll(\".\", \"\");\r\n\r\n /**\r\n * 4. Separate digits for checksum calculation\r\n * - first 12 digits: used to calculate checksum\r\n * - last digit: actual check digit\r\n */\r\n const digits = compactNumber.slice(0, -1);\r\n const reversedDigits = [...digits].reverse().join(\"\");\r\n const reversedDigitsArray = [...reversedDigits];\r\n\r\n /*\r\n * 5. Calculate weighted sum for checksum\r\n * - Even positions (after reversing) ×3\r\n * - Odd positions ×1\r\n */\r\n let sum = 0;\r\n for (const [i, element] of reversedDigitsArray.entries()) {\r\n sum += i % 2 === 0 ? Number(element) * 3 : Number(element) * 1;\r\n }\r\n\r\n /*\r\n * 6. Calculate expected check digit\r\n * - Check digit = value to reach next multiple of 10\r\n */\r\n const checksum = (10 - (sum % 10)) % 10;\r\n const checknumber = Number.parseInt(compactNumber.slice(-1));\r\n\r\n /*\r\n * 7. Compare calculated check digit with actual last digit\r\n * - If equal → valid AHV number\r\n */\r\n return checksum === checknumber;\r\n}\r\n\r\n/**\r\n * Attempts to parse and validate a Swiss IBAN.\r\n * @param unformattedIbanNumber - The unformatted IBAN as a string\r\n * @returns The result object with the following properties:\r\n * @property {boolean} isValid - Indicates whether the IBAN is valid or not\r\n * @property {string} iban - The cleaned IBAN, only present if valid\r\n * @property {string} ibanFormatted - The formatted IBAN, only present if valid\r\n */\r\nexport function tryParseSwissIbanNumber(unformattedIbanNumber?: string): {\r\n /**\r\n * Indicates whether the IBAN is valid or not\r\n */\r\n isValid: boolean;\r\n /**\r\n * The cleaned IBAN, only present if valid\r\n */\r\n iban?: string;\r\n /**\r\n * The formatted IBAN, only present if valid\r\n */\r\n ibanFormatted?: string;\r\n} {\r\n if (isNullOrWhitespace(unformattedIbanNumber)) {\r\n return { isValid: false };\r\n }\r\n\r\n const iban = unformattedIbanNumber!.replaceAll(/[^A-Z0-9]/gi, \"\").toUpperCase();\r\n const isValid = isValidSwissIbanNumber(iban);\r\n\r\n return {\r\n isValid: isValid,\r\n iban: isValid ? iban : undefined,\r\n ibanFormatted: isValid ? iban.match(/.{1,4}/g)?.join(\" \") : undefined,\r\n };\r\n}\r\n\r\n/**\r\n * Attempts to parse and validate a Swiss social insurance number.\r\n * @param unformattedInsuranceNumber - The unformatted Swiss social insurance number\r\n * @returns The result object with the following properties:\r\n * @property {boolean} isValid - Indicates whether the Swiss social insurance number is valid or not\r\n * @property {string} swissSocialInsuranceNumber - The cleaned Swiss social insurance number, only present if valid\r\n * @property {string} swissSocialInsuranceNumberFormatted - The formatted Swiss social insurance number, only present if valid\r\n */\r\nexport function tryParseSwissSocialInsuranceNumber(unformattedInsuranceNumber?: string): {\r\n /**\r\n * Indicates whether the Swiss social insurance number is valid or not\r\n */\r\n isValid: boolean;\r\n /**\r\n * The cleaned Swiss social insurance number, only present if valid\r\n */\r\n swissSocialInsuranceNumber?: string;\r\n /**\r\n * The formatted Swiss social insurance number, only present if valid\r\n */\r\n swissSocialInsuranceNumberFormatted?: string;\r\n} {\r\n if (isNullOrWhitespace(unformattedInsuranceNumber)) {\r\n return { isValid: false };\r\n }\r\n\r\n const insuranceNumber = unformattedInsuranceNumber!.replaceAll(/\\D/g, \"\");\r\n const isValid = isValidSwissSocialInsuranceNumber(insuranceNumber);\r\n\r\n return {\r\n isValid: isValid,\r\n swissSocialInsuranceNumber: isValid ? insuranceNumber : undefined,\r\n swissSocialInsuranceNumberFormatted: isValid ? insuranceNumber.replace(/^(\\d{3})(\\d{4})(\\d{4})(\\d{2})$/, \"$1.$2.$3.$4\") : undefined,\r\n };\r\n}\r\n"],"names":["isNullOrEmpty","value","length","isNullOrWhitespace","trim","capitalize","charAt","toUpperCase","slice","uncapitalize","toLowerCase","truncate","maxLength","suffix","trimStart","haystack","needle","offset","indexOf","trimEnd","idx","lastIndexOf","splitLines","str","removeEmptyEntries","trimEntries","splitted","split","map","x","filter","line","parseBool","replace","getEnumNameFromValue","enumVariable","enumValue","result","undefined","isEnumString","Object","keys","values","getEnumValueFromName","enumName","getEnumNames","names","getEnumValues","Number","parseInt","parseEnum","isNaN","key","test","CacheProvider","cacheName","cache","Map","constructor","this","createCacheKey","container","containerName","getObject","get","setObject","cacheObject","set","reset","delete","dateIsValid","date","isDate","isValid","dateIsFirstDayOfMonth","isFirstDayOfMonth","dateIsLastDayOfMonth","isLastDayOfMonth","dateIsLeapYear","isLeapYear","dateIsWeekend","isWeekend","dateDifferenceInDays","from","to","Math","abs","differenceInCalendarDays","NaN","getNextBusinessDate","addBusinessDays","Date","getStartOfDay","startOfDay","getEndOfDay","endOfDay","getFirstDayOfYear","getFullYear","getLastDayOfYear","lastDayOfYear","getQuarter","getQuarterInternal","addQuarters","amount","addQuartersInternal","getDateWithoutTimeZone","getTime","getTimezoneOffset","getDateAddTimeZone","newGuid","uuid","v4","isValidGuid","emptyGuid","NIL","checkLocalStorageSupport","localStorage","TypeError","getLocalStorageItem","item","getItem","parsedItem","JSON","parse","expirationDate","revivedExpirationDate","removeItem","data","setLocalStorageItem","setItem","stringify","removeLocalStorageItem","isMainMimeType","mimeType","mainType","normalizedMimeType","startsWith","isImageMimeType","isPdfMimeType","isVideoMimeType","isAudioMimeType","isTextMimeType","isApplicationMimeType","clamp","min","max","Error","roundPrecision","precision","multiplier","pow","round","isObject","obj","Array","isArray","RegExp","convertNullToUndefined","isValidSwissIbanNumber","ibanNumber","compactIbanNumberWithWhiteSpaces","compactIbanNumberWithoutWhiteSpaces","compactIbanNumber","replaceAll","numericStr","ch","codePointAt","toString","restOfCalculation","digit","isValidSwissSocialInsuranceNumber","socialInsuranceNumber","socialInsuranceNumberWithDots","socialInsuranceNumberWithoutDots","compactNumber","reversedDigitsArray","reverse","join","sum","i","element","entries","tryParseSwissIbanNumber","unformattedIbanNumber","iban","ibanFormatted","match","tryParseSwissSocialInsuranceNumber","unformattedInsuranceNumber","insuranceNumber","swissSocialInsuranceNumber","swissSocialInsuranceNumberFormatted"],"mappings":"uRAKM,SAAUA,EAAcC,GAC5B,OAAKA,GAA0B,iBAAVA,GAIG,IAAjBA,EAAMC,MACf,CAOM,SAAUC,EAAmBF,GACjC,OAAOD,EAAcC,IAA8C,IAAnCA,EAAiBG,OAAOF,MAC1D,CAOM,SAAUG,EAAWJ,GACzB,OAAKA,GAASE,EAAmBF,GACxBA,EAGFA,EAAMK,OAAO,GAAGC,cAAgBN,EAAMO,MAAM,EACrD,CAOM,SAAUC,EAAaR,GAC3B,OAAKA,GAASE,EAAmBF,GACxBA,EAGFA,EAAMK,OAAO,GAAGI,cAAgBT,EAAMO,MAAM,EACrD,CASM,SAAUG,EAASV,EAA2BW,EAAmBC,EAAS,IAC9E,OAAKZ,GAASE,EAAmBF,IAI7BA,EAAMC,QAAUU,EAHXX,EAOF,GAAGA,EAAMO,MAAM,EAAGI,KAAaC,GACxC,CAQgB,SAAAC,EAAUC,EAAkBC,GAC1C,GAAIhB,EAAce,IAAaf,EAAcgB,GAC3C,OAAOD,EAGT,IAAIE,EAAS,EAEb,KAAOF,EAASG,QAAQF,EAAQC,KAAYA,GAC1CA,GAAkBD,EAAOd,OAE3B,OAAOa,EAASP,MAAMS,EACxB,CAQgB,SAAAE,EAAQJ,EAAkBC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AAO,8BAC3CiB,EAAmC,IAAIjB,OAAO,eAEpD,IAAKgB,EAA8BvH,KAAKsH,KAA2BE,EAAiCxH,KAAKsH,GACvG,OAAO,EAIT,MAAMG,EAAgBH,EAAsBR,WAAW,IAAK,IAStDY,EAAsB,IADL,IADRD,EAActK,MAAM,GAAI,IACJwK,UAAUC,KAAK,KAQlD,IAAIC,EAAM,EACV,IAAK,MAAOC,EAAGC,KAAYL,EAAoBM,UAC7CH,GAAOC,EAAI,GAAM,EAAsB,EAAlBnI,OAAOoI,GAAiC,EAAlBpI,OAAOoI,GAcpD,OAPkB,GAAMF,EAAM,IAAO,KACjBlI,OAAOC,SAAS6H,EAActK,OAAO,GAO3D,CAUM,SAAU8K,GAAwBC,GActC,GAAIpL,EAAmBoL,GACrB,MAAO,CAAE9G,SAAS,GAGpB,MAAM+G,EAAOD,EAAuBpB,WAAW,cAAe,IAAI5J,cAC5DkE,EAAUqF,GAAuB0B,GAEvC,MAAO,CACL/G,QAASA,EACT+G,KAAM/G,EAAU+G,OAAOlJ,EACvBmJ,cAAehH,EAAU+G,EAAKE,MAAM,YAAYT,KAAK,UAAO3I,EAEhE,CAUM,SAAUqJ,GAAmCC,GAcjD,GAAIzL,EAAmByL,GACrB,MAAO,CAAEnH,SAAS,GAGpB,MAAMoH,EAAkBD,EAA4BzB,WAAW,MAAO,IAChE1F,EAAUiG,GAAkCmB,GAElD,MAAO,CACLpH,QAASA,EACTqH,2BAA4BrH,EAAUoH,OAAkBvJ,EACxDyJ,oCAAqCtH,EAAUoH,EAAgB5J,QAAQ,iCAAkC,oBAAiBK,EAE9H"}
|
|
1
|
+
{"version":3,"file":"index.modern.js","sources":["../src/lib/string.ts","../src/lib/boolean.ts","../src/lib/enum.ts","../src/lib/cacheProvider.ts","../src/lib/date.ts","../src/lib/guid.ts","../src/lib/localStorage.ts","../src/lib/mimeType.ts","../src/lib/number.ts","../src/lib/object.ts","../src/lib/swissStandards.ts"],"sourcesContent":["/**\r\n * Indicates whether a specified string is null/undefined or empty\r\n * @param value The string to test\r\n * @returns true if the value parameter is null/undefined or empty\r\n */\r\nexport function isNullOrEmpty(value?: string): boolean {\r\n if (!value || typeof value !== \"string\") {\r\n return true;\r\n }\r\n\r\n return value.length === 0;\r\n}\r\n\r\n/**\r\n * Indicates whether a specified string is null/undefined, empty, or consists only of white-space characters\r\n * @param value The string to test\r\n * @returns true if the value parameter is null/undefined, Empty, or if value consists exclusively of white-space characters\r\n */\r\nexport function isNullOrWhitespace(value?: string): boolean {\r\n return isNullOrEmpty(value) || (value as string).trim().length === 0;\r\n}\r\n\r\n/**\r\n * Capitalize the string\r\n * @param value The string to capitalize\r\n * @returns The capitalized string\r\n */\r\nexport function capitalize(value?: string): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n return value.charAt(0).toUpperCase() + value.slice(1);\r\n}\r\n\r\n/**\r\n * Uncapitalize the string\r\n * @param value The string to uncapitalize\r\n * @returns The uncapitalized string\r\n */\r\nexport function uncapitalize(value?: string): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n return value.charAt(0).toLowerCase() + value.slice(1);\r\n}\r\n\r\n/**\r\n * Truncates a string to a maximum length, adding a suffix if truncated\r\n * @param value The string to truncate\r\n * @param maxLength The maximum length of the resulting string\r\n * @param suffix The suffix to append if truncated (default: \"\")\r\n * @returns The truncated string\r\n */\r\nexport function truncate(value: string | undefined, maxLength: number, suffix = \"\"): string | undefined {\r\n if (!value || isNullOrWhitespace(value)) {\r\n return value;\r\n }\r\n\r\n if (value.length <= maxLength) {\r\n return value;\r\n }\r\n\r\n return `${value.slice(0, maxLength)}${suffix}`;\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the start of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the left side\r\n */\r\nexport function trimStart(haystack: string, needle: string): string {\r\n if (isNullOrEmpty(haystack) || isNullOrEmpty(needle)) {\r\n return haystack;\r\n }\r\n\r\n let offset = 0;\r\n\r\n while (haystack.indexOf(needle, offset) === offset) {\r\n offset = offset + needle.length;\r\n }\r\n return haystack.slice(offset);\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the end of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the right side\r\n */\r\nexport function trimEnd(haystack: string, needle: string): string {\r\n if (isNullOrEmpty(haystack) || isNullOrEmpty(needle)) {\r\n return haystack;\r\n }\r\n\r\n let offset = haystack.length,\r\n idx = -1;\r\n\r\n while (true) {\r\n idx = haystack.lastIndexOf(needle, offset - 1);\r\n if (idx === -1 || idx + needle.length !== offset) {\r\n break;\r\n }\r\n if (idx === 0) {\r\n return \"\";\r\n }\r\n offset = idx;\r\n }\r\n\r\n return haystack.slice(0, offset);\r\n}\r\n\r\n/**\r\n * Removes all occurrences of needle from the start and the end of haystack\r\n * @param haystack string to trim\r\n * @param needle the thing to trim\r\n * @returns the string trimmed from the right and left side\r\n */\r\nexport function trim(haystack: string, needle: string): string {\r\n const trimmed = trimStart(haystack, needle);\r\n return trimEnd(trimmed, needle);\r\n}\r\n\r\n/**\r\n * Splits the string at line breaks\r\n * @param str the string to split\r\n * @param removeEmptyEntries the option to remove empty entries\r\n * @param trimEntries the option to trim the entries\r\n * @returns the individual lines as an array\r\n */\r\nexport function splitLines(str: string, removeEmptyEntries: boolean = false, trimEntries: boolean = false): string[] {\r\n if (isNullOrEmpty(str)) {\r\n return [];\r\n }\r\n\r\n let splitted = str.split(/\\r\\n|\\r|\\n/);\r\n\r\n if (trimEntries) {\r\n splitted = splitted.map((x) => x.trim());\r\n }\r\n\r\n if (removeEmptyEntries) {\r\n splitted = splitted.filter((line) => line.length > 0);\r\n }\r\n\r\n return splitted;\r\n}\r\n","import { isNullOrEmpty } from \"./string\";\r\n\r\n/**\r\n * Converts a string to a boolean\r\n * @param value The string to convert\r\n * @returns The parsed boolean\r\n */\r\nexport function parseBool(value?: string): boolean {\r\n // Similar to C# implementation that trims also null characters\r\n // https://github.com/dotnet/runtime/blob/main/src/libraries/System.Private.CoreLib/src/System/Boolean.cs#L277\r\n return !isNullOrEmpty(value) && value?.replace(/[\\s\\0]/g, \"\").toLowerCase() === \"true\";\r\n}\r\n","/**\n * The standard enum type\n */\nexport type StandardEnum<T> = {\n [id: string]: T | string;\n [nu: number]: string;\n};\n\n/**\n * Returns the name of an enum from its value\n * @param enumVariable The enum for which you want to get the name\n * @param enumValue The value of the enum for which you want to get the name\n * @returns A string containing the name of the enum\n */\nexport function getEnumNameFromValue<T>(enumVariable: StandardEnum<T>, enumValue: T): string {\n let result = enumVariable[enumValue as keyof StandardEnum<T>] as string;\n\n if (result === undefined && isEnumString(enumVariable)) {\n result = Object.keys(enumVariable)[Object.values(enumVariable).indexOf(enumValue)];\n }\n\n return result;\n}\n\n/**\n * Returns the value of an enum from its name\n * @param enumVariable The enum for which you want to get the value\n * @param enumName The name of the enum for which you want to get the value\n * @returns A string containing the value of the enum\n */\nexport function getEnumValueFromName<T>(enumVariable: StandardEnum<T>, enumName: string): T {\n return enumVariable[enumName as keyof StandardEnum<T>] as T;\n}\n\n/**\n * Returns all the names of an enum\n * @param enumVariable The enum for which you want to get the names\n * @returns A string array containing the names of the enum\n */\nexport function getEnumNames<T>(enumVariable: StandardEnum<T>) {\n const names = Object.values(enumVariable);\n\n // If enum is with values integer, object.values returns a list of [names, values].\n return isEnumString(enumVariable) ? Object.keys(enumVariable) : names.slice(0, names.length / 2);\n}\n\n/**\n * Returns all the values of an enum\n * @param enumVariable The enum for which you want to get the values\n * @returns A string or number array containing the values of the enum\n */\nexport function getEnumValues<T>(enumVariable: StandardEnum<T>): T[] {\n const keys = Object.keys(enumVariable);\n\n // If enum is with values integer, object.keys returns a list of [values, names].\n return (\n isEnumString(enumVariable) ? Object.values(enumVariable) : keys.slice(0, keys.length / 2).map((value) => Number.parseInt(value))\n ) as T[];\n}\n\n/**\n * Parses a string to an enum value\n * @param enumVariable The enum for which you want to get the values\n * @param value The string to parse\n * @returns The enum value corresponding to the string, or undefined if not found\n */\nexport function parseEnum<T>(enumVariable: StandardEnum<T>, value: string): T | undefined {\n if (!isEnumString(enumVariable) && Number.isNaN(Number(value))) {\n return undefined;\n }\n\n return getEnumValueFromName(enumVariable, getEnumNameFromValue(enumVariable, value as T));\n}\n\n/**\n * Returns if it's a enum with string value\n * @param enumVariable The enum\n * @returns A bool\n */\nfunction isEnumString<T>(enumVariable: StandardEnum<T>) {\n for (const key in enumVariable) {\n return !/^\\d+$/.test(key);\n }\n\n return false;\n}\n","import { getEnumNameFromValue, StandardEnum } from \"./enum\";\r\nimport { isNullOrWhitespace } from \"./string\";\r\n\r\n/**\r\n * Methods to help caching data of any type.\r\n * Data is put in containers and may be identified by a string key.\r\n * Data can be saved, retrieved and reset.\r\n * Based on Neolution.Abstractions.Caching.CacheProvider<TEnum>\r\n * Ref: https://github.com/neolution-ch/Neolution.Abstractions/blob/main/Neolution.Abstractions/Caching/CacheProvider.cs\r\n */\r\nexport class CacheProvider<TEnum> {\r\n /**\r\n * The enum variable\r\n */\r\n private readonly enumVariable: StandardEnum<TEnum>;\r\n\r\n /**\r\n * The name of the cache\r\n */\r\n private readonly cacheName: string;\r\n\r\n /**\r\n * The cache\r\n */\r\n private readonly cache = new Map<string, object>();\r\n\r\n /**\r\n * Initializes a new instance of the CacheProvider<TEnum> class\r\n * @param enumVariable The enum variable\r\n * @param cacheName The name of the cache\r\n */\r\n constructor(enumVariable: StandardEnum<TEnum>, cacheName: string) {\r\n this.enumVariable = enumVariable;\r\n this.cacheName = cacheName;\r\n }\r\n\r\n /**\r\n * Creates the cache key\r\n * @param container The container\r\n * @param key The key\r\n * @returns The cache key\r\n */\r\n private createCacheKey(container: TEnum, key?: string): string {\r\n let containerName = getEnumNameFromValue(this.enumVariable, container);\r\n\r\n if (key && !isNullOrWhitespace(key)) {\r\n containerName = `${containerName}_${key}`;\r\n }\r\n\r\n return `${this.cacheName}:${containerName}`;\r\n }\r\n\r\n /**\r\n * Gets cached data from the specified container\r\n * @param container The container\r\n * @param key The key\r\n * @returns The data from cache\r\n */\r\n getObject<T>(container: TEnum, key?: string): T | undefined {\r\n return this.cache.get(this.createCacheKey(container, key)) as T;\r\n }\r\n\r\n /**\r\n * Sets cached data identified by a key in the specified container\r\n * @param container The container\r\n * @param key The key\r\n * @param cacheObject The cache object\r\n */\r\n setObject<T>(container: TEnum, key: string | undefined, cacheObject: T): void {\r\n this.cache.set(this.createCacheKey(container, key), cacheObject as object);\r\n }\r\n\r\n /**\r\n * Resets cached data identified by a key of the specified container\r\n * @param container The container\r\n * @param key The key\r\n */\r\n reset(container: TEnum, key?: string): void {\r\n this.cache.delete(this.createCacheKey(container, key));\r\n }\r\n}\r\n","import {\r\n isDate,\r\n isValid,\r\n isFirstDayOfMonth,\r\n isLastDayOfMonth,\r\n isLeapYear,\r\n isWeekend,\r\n differenceInCalendarDays,\r\n addBusinessDays,\r\n startOfDay,\r\n endOfDay,\r\n lastDayOfYear,\r\n getQuarter as getQuarterInternal,\r\n addQuarters as addQuartersInternal,\r\n} from \"date-fns\";\r\n\r\n/**\r\n * Check whether the date is valid\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is valid\r\n */\r\nexport function dateIsValid(date: Date): boolean {\r\n return isDate(date) && isValid(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is the first day of the month\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is the first day of the month\r\n */\r\nexport function dateIsFirstDayOfMonth(date: Date): boolean {\r\n return dateIsValid(date) && isFirstDayOfMonth(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is the last day of the month\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is the last day of the month\r\n */\r\nexport function dateIsLastDayOfMonth(date: Date): boolean {\r\n return dateIsValid(date) && isLastDayOfMonth(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is a leap year\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is a leap year\r\n */\r\nexport function dateIsLeapYear(date: Date): boolean {\r\n return dateIsValid(date) && isLeapYear(date);\r\n}\r\n\r\n/**\r\n * Check whether the date is a weekend\r\n * @param date The date\r\n * @returns A boolean indicating whether the date is a weekend\r\n */\r\nexport function dateIsWeekend(date: Date): boolean {\r\n return dateIsValid(date) && isWeekend(date);\r\n}\r\n\r\n/**\r\n * Calculate the difference in days between two dates\r\n * The order is not relevant hence the result is always positive\r\n * @param from The start date\r\n * @param to The end date\r\n * @returns The difference in days between two dates\r\n */\r\nexport function dateDifferenceInDays(from: Date, to: Date): number {\r\n return dateIsValid(from) && dateIsValid(to) ? Math.abs(differenceInCalendarDays(from, to)) : Number.NaN;\r\n}\r\n\r\n/**\r\n * Get the next business date\r\n * @param date The date\r\n * @returns The next business date\r\n */\r\nexport function getNextBusinessDate(date: Date): Date {\r\n return dateIsValid(date) ? addBusinessDays(date, 1) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the start of a day for the given date\r\n * @param date The date\r\n * @returns The start of a day date\r\n */\r\nexport function getStartOfDay(date: Date): Date {\r\n return dateIsValid(date) ? startOfDay(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the end of a day for the given date\r\n * @param date The date\r\n * @returns The end of a day date\r\n */\r\nexport function getEndOfDay(date: Date): Date {\r\n return dateIsValid(date) ? endOfDay(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the first day of a year for the given date\r\n * @param date The date\r\n * @returns The first day of the date year\r\n */\r\nexport function getFirstDayOfYear(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getFullYear(), 0, 1) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the last day of a year for the given date\r\n * @param date The date\r\n * @returns The last day of the date year\r\n */\r\nexport function getLastDayOfYear(date: Date): Date {\r\n return dateIsValid(date) ? lastDayOfYear(date) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the year quarter for the given date\r\n * @param date The date\r\n * @returns The year quarter\r\n */\r\nexport function getQuarter(date: Date): number {\r\n return dateIsValid(date) ? getQuarterInternal(date) : Number.NaN;\r\n}\r\n\r\n/**\r\n * Shifts a date by a given number of quarters.\r\n * @param date The date\r\n * @param amount Number of quarters to shift by (negative values shift the date backwards)\r\n * @returns A new Date shifted by the specified number of quarters\r\n */\r\nexport function addQuarters(date: Date, amount: number): Date {\r\n return dateIsValid(date) ? addQuartersInternal(date, amount) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the date removing the time-zone offset\r\n * @param date The date\r\n * @returns the given date removing the time-zone offset\r\n */\r\nexport function getDateWithoutTimeZone(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getTime() - date.getTimezoneOffset() * 60_000) : new Date(Number.NaN);\r\n}\r\n\r\n/**\r\n * Get the date adding the time-zone offset\r\n * @param date The date\r\n * @returns the given date adding the time-zone offset\r\n */\r\nexport function getDateAddTimeZone(date: Date): Date {\r\n return dateIsValid(date) ? new Date(date.getTime() + date.getTimezoneOffset() * 60_000) : new Date(Number.NaN);\r\n}\r\n","import * as uuid from \"uuid\";\n\n/**\n * Create a new Guid (version 4 UUID)\n * @returns A new Guid\n */\nexport function newGuid() {\n return uuid.v4();\n}\n\n/**\n * Check whether a string it is a valid Guid\n * @param str The string to test whether it is a valid Guid\n * @returns A value indicating whether the string is a valid Guid\n */\nexport function isValidGuid(str: string) {\n const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n return typeof str === \"string\" && regex.test(str);\n}\n\n/**\n * The empty Guid (an identifier containing all zeros)\n */\nexport const emptyGuid: string = uuid.NIL;\n","import { dateIsValid } from \"./date\";\r\n\r\n/**\r\n * The localStorage item\r\n */\r\ninterface LocalStorageItem<T> {\r\n /**\r\n * The data\r\n */\r\n data: T;\r\n\r\n /**\r\n * The expiration date\r\n */\r\n expirationDate?: Date;\r\n}\r\n\r\n/**\r\n * Check if the localStorage is supported\r\n */\r\nconst checkLocalStorageSupport = () => {\r\n if (typeof localStorage === \"undefined\") {\r\n throw new TypeError(\"localStorage not supported\");\r\n }\r\n};\r\n\r\n/**\r\n * Get an item from the localStorage\r\n * @param key The key\r\n * @returns The item\r\n */\r\nexport function getLocalStorageItem<T>(key: string): T | undefined {\r\n checkLocalStorageSupport();\r\n\r\n const item = localStorage.getItem(key);\r\n if (!item) {\r\n return undefined;\r\n }\r\n\r\n const parsedItem = JSON.parse(item) as LocalStorageItem<T>;\r\n\r\n if (parsedItem.expirationDate) {\r\n const revivedExpirationDate = new Date(parsedItem.expirationDate);\r\n if (dateIsValid(revivedExpirationDate) && revivedExpirationDate < new Date()) {\r\n localStorage.removeItem(key);\r\n return undefined;\r\n }\r\n }\r\n\r\n return parsedItem.data;\r\n}\r\n\r\n/**\r\n * Set an item in the localStorage\r\n * @param key The key\r\n * @param data The item data\r\n * @param expirationDate The expiration date\r\n */\r\nexport function setLocalStorageItem<T>(key: string, data: T, expirationDate?: Date): void {\r\n checkLocalStorageSupport();\r\n localStorage.setItem(key, JSON.stringify({ data, expirationDate }));\r\n}\r\n\r\n/**\r\n * Remove an item from the localStorage\r\n * @param key The key\r\n */\r\nexport function removeLocalStorageItem(key: string): void {\r\n checkLocalStorageSupport();\r\n localStorage.removeItem(key);\r\n}\r\n","import { isNullOrEmpty } from \"./string\";\n\n/**\n * Private helper function to check if a MIME type matches a main type pattern\n * @param mimeType The MIME type to check\n * @param mainType The main MIME type (e.g., \"image\", \"video\")\n * @returns true if the MIME type matches the pattern\n */\nfunction isMainMimeType(mimeType: string, mainType: string): boolean {\n const normalizedMimeType = mimeType.toLowerCase().trim();\n return normalizedMimeType.startsWith(`${mainType}/`) && normalizedMimeType.length > mainType.length + 1;\n}\n\n/**\n * Check if the MIME type represents an image\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for an image\n */\nexport function isImageMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n return isMainMimeType(mimeType!, \"image\");\n}\n\n/**\n * Check if the MIME type represents a PDF document\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for a PDF document\n */\nexport function isPdfMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n const normalizedMimeType = mimeType!.toLowerCase().trim();\n return normalizedMimeType === \"application/pdf\";\n}\n\n/**\n * Check if the MIME type represents a video\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for a video\n */\nexport function isVideoMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n return isMainMimeType(mimeType!, \"video\");\n}\n\n/**\n * Check if the MIME type represents an audio file\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for an audio file\n */\nexport function isAudioMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n return isMainMimeType(mimeType!, \"audio\");\n}\n\n/**\n * Check if the MIME type represents a text file\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for a text file\n */\nexport function isTextMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n return isMainMimeType(mimeType!, \"text\");\n}\n\n/**\n * Check if the MIME type represents an application file\n * @param mimeType The MIME type to check\n * @returns true if the MIME type is for an application file\n */\nexport function isApplicationMimeType(mimeType?: string): boolean {\n if (isNullOrEmpty(mimeType)) {\n return false;\n }\n\n return isMainMimeType(mimeType!, \"application\");\n}\n","/**\r\n * Returns a number whose value is limited to the given range\r\n * @param value The initial value\r\n * @param min The lower boundary\r\n * @param max The upper boundary\r\n * @returns A number in the range (min, max)\r\n */\r\nexport function clamp(value: number, min: number, max: number): number {\r\n if (min > max) {\r\n throw new Error(`'${min}' cannot be greater than '${max}'.`);\r\n }\r\n return Math.min(Math.max(value, min), max);\r\n}\r\n\r\n/**\r\n * Round a number with the specified precision\r\n * @param value The number to round\r\n * @param precision The desired precision\r\n * @returns The number rounded with the specified precision\r\n */\r\nexport function roundPrecision(value: number, precision: number): number {\r\n const multiplier = Math.pow(10, precision);\r\n return Math.round(value * multiplier) / multiplier;\r\n}\r\n","/**\r\n * Check whether the provided parameter is of type `object` but not `null`, an `array`, a `regexp`, nor a `date`\r\n * @param obj The object\r\n * @returns A boolean indicating whether the parameter is an object\r\n */\r\nexport const isObject = (obj: object): boolean =>\r\n typeof obj === \"object\" && obj !== null && !Array.isArray(obj) && !(obj instanceof RegExp) && !(obj instanceof Date);\r\n\r\n/**\r\n * Convert null properties to undefined\r\n * @param obj The object\r\n */\r\nexport const convertNullToUndefined = (obj: object | object[]): void => {\r\n if (Array.isArray(obj)) {\r\n for (const item of obj as unknown as object[]) {\r\n if (item === null) {\r\n obj[obj.indexOf(item)] = undefined;\r\n } else if (isObject(item)) {\r\n convertNullToUndefined(item);\r\n }\r\n }\r\n } else if (!isObject(obj)) {\r\n return;\r\n }\r\n\r\n for (const key of Object.keys(obj)) {\r\n const value = obj[key as keyof typeof obj];\r\n if (value === null) {\r\n delete obj[key as keyof typeof obj];\r\n } else if (isObject(value) || Array.isArray(value)) {\r\n convertNullToUndefined(value);\r\n }\r\n }\r\n};\r\n","import { isNullOrWhitespace } from \"./string\";\n\n/**\n * Checks if the provided string is a valid swiss IBAN number\n * @param ibanNumber The provided IBAN number to check\n * Must be in one of the following formats:\n * - \"CHXX XXXX XXXX XXXX XXXX X\" with whitespaces\n * - \"CHXXXXXXXXXXXXXXXXXXX\" without whitespaces\n * @returns The result of the IBAN number check\n */\nexport function isValidSwissIbanNumber(ibanNumber: string): boolean {\n // 1. Reject null, undefined or whitespace-only strings\n if (isNullOrWhitespace(ibanNumber)) {\n return false;\n }\n\n // 2. Define allowed strict formats\n // - with spaces: \"CHXX XXXX XXXX XXXX XXXX X\"\n const compactIbanNumberWithWhiteSpaces = new RegExp(/^CH[0-9]{2} [0-9]{4} [0-9][A-Z0-9]{3} [A-Z0-9]{4} [A-Z0-9]{4} [A-Z0-9]$/);\n // - without spaces: \"CHXXXXXXXXXXXXXXXXXXX\"\n const compactIbanNumberWithoutWhiteSpaces = new RegExp(/^CH[0-9]{7}[A-Z0-9]{12}$/);\n\n // 3. Check if the input matches one of the allowed formats\n if (!(compactIbanNumberWithWhiteSpaces.test(ibanNumber) || compactIbanNumberWithoutWhiteSpaces.test(ibanNumber))) {\n return false;\n }\n\n // 4. Remove all spaces to get a compact IBAN string\n const compactIbanNumber = ibanNumber.replaceAll(\" \", \"\");\n\n // 5. Rearrange IBAN for checksum calculation\n // - move first 4 characters (CH + 2 check digits) to the end\n const rearrangedIban = compactIbanNumber.slice(4) + compactIbanNumber.slice(0, 4);\n\n // 6. Replace letters with numbers (A=10, B=11, ..., Z=35)\n const numericStr = rearrangedIban.replaceAll(/[A-Z]/g, (ch) => (ch.codePointAt(0)! - 55).toString());\n\n // 7. Perform modulo 97 calculation to validate IBAN\n let restOfCalculation = 0;\n for (const digit of numericStr) {\n restOfCalculation = (restOfCalculation * 10 + Number(digit)) % 97;\n }\n\n // 8. IBAN is valid only if the remainder equals 1\n return restOfCalculation === 1;\n}\n\n/**\n * Validation of a social insurance number with checking the checksum\n * Validation according to https://www.sozialversicherungsnummer.ch/aufbau-neu.htm\n * @param socialInsuranceNumber The social insurance number to check\n * Must be in one of the following formats:\n * - \"756.XXXX.XXXX.XX\" with dots as separators\n * - \"756XXXXXXXXXX\" with digits only\n * @returns The result if the social insurance number is valid or not\n */\nexport function isValidSwissSocialInsuranceNumber(socialInsuranceNumber: string): boolean {\n // 1. Check if the input is empty or only a whitespace\n if (isNullOrWhitespace(socialInsuranceNumber)) {\n return false;\n }\n\n /**\n * 2. Check if the input matches one of the accepted formats:\n * - With dots: 756.XXXX.XXXX.XX\n * - Without dots: 756XXXXXXXXXX\n */\n const socialInsuranceNumberWithDots = new RegExp(/^756\\.\\d{4}\\.\\d{4}\\.\\d{2}$/);\n const socialInsuranceNumberWithoutDots = new RegExp(/^756\\d{10}$/);\n\n if (!socialInsuranceNumberWithDots.test(socialInsuranceNumber) && !socialInsuranceNumberWithoutDots.test(socialInsuranceNumber)) {\n return false;\n }\n\n // 3. Remove all dots → get a string of 13 digits\n const compactNumber = socialInsuranceNumber.replaceAll(\".\", \"\");\n\n /**\n * 4. Separate digits for checksum calculation\n * - first 12 digits: used to calculate checksum\n * - last digit: actual check digit\n */\n const digits = compactNumber.slice(0, -1);\n const reversedDigits = [...digits].reverse().join(\"\");\n const reversedDigitsArray = [...reversedDigits];\n\n /*\n * 5. Calculate weighted sum for checksum\n * - Even positions (after reversing) ×3\n * - Odd positions ×1\n */\n let sum = 0;\n for (const [i, element] of reversedDigitsArray.entries()) {\n sum += i % 2 === 0 ? Number(element) * 3 : Number(element) * 1;\n }\n\n /*\n * 6. Calculate expected check digit\n * - Check digit = value to reach next multiple of 10\n */\n const checksum = (10 - (sum % 10)) % 10;\n const checknumber = Number.parseInt(compactNumber.slice(-1));\n\n /*\n * 7. Compare calculated check digit with actual last digit\n * - If equal → valid AHV number\n */\n return checksum === checknumber;\n}\n\n/**\n * Attempts to parse and validate a Swiss IBAN.\n * @param unformattedIbanNumber - The unformatted IBAN as a string\n * @returns The result object with the following properties:\n * @property {boolean} isValid - Indicates whether the IBAN is valid or not\n * @property {string} iban - The cleaned IBAN, only present if valid\n * @property {string} ibanFormatted - The formatted IBAN, only present if valid\n */\nexport function tryParseSwissIbanNumber(unformattedIbanNumber?: string): {\n /**\n * Indicates whether the IBAN is valid or not\n */\n isValid: boolean;\n /**\n * The cleaned IBAN, only present if valid\n */\n iban?: string;\n /**\n * The formatted IBAN, only present if valid\n */\n ibanFormatted?: string;\n} {\n if (isNullOrWhitespace(unformattedIbanNumber)) {\n return { isValid: false };\n }\n\n const iban = unformattedIbanNumber!.replaceAll(/[^A-Z0-9]/gi, \"\").toUpperCase();\n const isValid = isValidSwissIbanNumber(iban);\n\n return {\n isValid: isValid,\n iban: isValid ? iban : undefined,\n ibanFormatted: isValid ? iban.match(/.{1,4}/g)?.join(\" \") : undefined,\n };\n}\n\n/**\n * Attempts to parse and validate a Swiss social insurance number.\n * @param unformattedInsuranceNumber - The unformatted Swiss social insurance number\n * @returns The result object with the following properties:\n * @property {boolean} isValid - Indicates whether the Swiss social insurance number is valid or not\n * @property {string} swissSocialInsuranceNumber - The cleaned Swiss social insurance number, only present if valid\n * @property {string} swissSocialInsuranceNumberFormatted - The formatted Swiss social insurance number, only present if valid\n */\nexport function tryParseSwissSocialInsuranceNumber(unformattedInsuranceNumber?: string): {\n /**\n * Indicates whether the Swiss social insurance number is valid or not\n */\n isValid: boolean;\n /**\n * The cleaned Swiss social insurance number, only present if valid\n */\n swissSocialInsuranceNumber?: string;\n /**\n * The formatted Swiss social insurance number, only present if valid\n */\n swissSocialInsuranceNumberFormatted?: string;\n} {\n if (isNullOrWhitespace(unformattedInsuranceNumber)) {\n return { isValid: false };\n }\n\n const insuranceNumber = unformattedInsuranceNumber!.replaceAll(/\\D/g, \"\");\n const isValid = isValidSwissSocialInsuranceNumber(insuranceNumber);\n\n return {\n isValid: isValid,\n swissSocialInsuranceNumber: isValid ? insuranceNumber : undefined,\n swissSocialInsuranceNumberFormatted: isValid ? insuranceNumber.replace(/^(\\d{3})(\\d{4})(\\d{4})(\\d{2})$/, \"$1.$2.$3.$4\") : undefined,\n };\n}\n"],"names":["isNullOrEmpty","value","length","isNullOrWhitespace","trim","capitalize","charAt","toUpperCase","slice","uncapitalize","toLowerCase","truncate","maxLength","suffix","trimStart","haystack","needle","offset","indexOf","trimEnd","idx","lastIndexOf","splitLines","str","removeEmptyEntries","trimEntries","splitted","split","map","x","filter","line","parseBool","replace","getEnumNameFromValue","enumVariable","enumValue","result","undefined","isEnumString","Object","keys","values","getEnumValueFromName","enumName","getEnumNames","names","getEnumValues","Number","parseInt","parseEnum","isNaN","key","test","CacheProvider","cacheName","cache","Map","constructor","this","createCacheKey","container","containerName","getObject","get","setObject","cacheObject","set","reset","delete","dateIsValid","date","isDate","isValid","dateIsFirstDayOfMonth","isFirstDayOfMonth","dateIsLastDayOfMonth","isLastDayOfMonth","dateIsLeapYear","isLeapYear","dateIsWeekend","isWeekend","dateDifferenceInDays","from","to","Math","abs","differenceInCalendarDays","NaN","getNextBusinessDate","addBusinessDays","Date","getStartOfDay","startOfDay","getEndOfDay","endOfDay","getFirstDayOfYear","getFullYear","getLastDayOfYear","lastDayOfYear","getQuarter","getQuarterInternal","addQuarters","amount","addQuartersInternal","getDateWithoutTimeZone","getTime","getTimezoneOffset","getDateAddTimeZone","newGuid","uuid","v4","isValidGuid","emptyGuid","NIL","checkLocalStorageSupport","localStorage","TypeError","getLocalStorageItem","item","getItem","parsedItem","JSON","parse","expirationDate","revivedExpirationDate","removeItem","data","setLocalStorageItem","setItem","stringify","removeLocalStorageItem","isMainMimeType","mimeType","mainType","normalizedMimeType","startsWith","isImageMimeType","isPdfMimeType","isVideoMimeType","isAudioMimeType","isTextMimeType","isApplicationMimeType","clamp","min","max","Error","roundPrecision","precision","multiplier","pow","round","isObject","obj","Array","isArray","RegExp","convertNullToUndefined","isValidSwissIbanNumber","ibanNumber","compactIbanNumberWithWhiteSpaces","compactIbanNumberWithoutWhiteSpaces","compactIbanNumber","replaceAll","numericStr","ch","codePointAt","toString","restOfCalculation","digit","isValidSwissSocialInsuranceNumber","socialInsuranceNumber","socialInsuranceNumberWithDots","socialInsuranceNumberWithoutDots","compactNumber","reversedDigitsArray","reverse","join","sum","i","element","entries","tryParseSwissIbanNumber","unformattedIbanNumber","iban","ibanFormatted","match","tryParseSwissSocialInsuranceNumber","unformattedInsuranceNumber","insuranceNumber","swissSocialInsuranceNumber","swissSocialInsuranceNumberFormatted"],"mappings":"uRAKM,SAAUA,EAAcC,GAC5B,OAAKA,GAA0B,iBAAVA,GAIG,IAAjBA,EAAMC,MACf,CAOM,SAAUC,EAAmBF,GACjC,OAAOD,EAAcC,IAA8C,IAAnCA,EAAiBG,OAAOF,MAC1D,CAOM,SAAUG,EAAWJ,GACzB,OAAKA,GAASE,EAAmBF,GACxBA,EAGFA,EAAMK,OAAO,GAAGC,cAAgBN,EAAMO,MAAM,EACrD,CAOM,SAAUC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AmByL,GACrB,MAAO,CAAEnH,SAAS,GAGpB,MAAMoH,EAAkBD,EAA4BzB,WAAW,MAAO,IAChE1F,EAAUiG,GAAkCmB,GAElD,MAAO,CACLpH,QAASA,EACTqH,2BAA4BrH,EAAUoH,OAAkBvJ,EACxDyJ,oCAAqCtH,EAAUoH,EAAgB5J,QAAQ,iCAAkC,oBAAiBK,EAE9H"}
|
package/package.json
CHANGED
|
@@ -1,84 +1,82 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@collana-solutions/javascript-utils",
|
|
3
|
-
"version": "2.6.
|
|
4
|
-
"description": "This is a collection of utilities that we have created to help with our development process.",
|
|
5
|
-
"homepage": "https://github.com/collana-solutions/javascript-utils#readme",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/collana-solutions/javascript-utils"
|
|
9
|
-
},
|
|
10
|
-
"license": "MIT",
|
|
11
|
-
"author": "collana solutions AG",
|
|
12
|
-
"sideEffects": false,
|
|
13
|
-
"exports": {
|
|
14
|
-
"./package.json": "./package.json",
|
|
15
|
-
".": {
|
|
16
|
-
"types": "./dist/src/index.d.ts",
|
|
17
|
-
"import": "./dist/index.modern.js",
|
|
18
|
-
"require": "./dist/index.js"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"main": "dist/index.js",
|
|
22
|
-
"module": "dist/index.modern.js",
|
|
23
|
-
"source": "src/index.ts",
|
|
24
|
-
"jsnext:main": "dist/index.modern.js",
|
|
25
|
-
"types": "dist/src/index.d.ts",
|
|
26
|
-
"files": [
|
|
27
|
-
"dist"
|
|
28
|
-
],
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"rollup-plugin-
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"packageManager": "pnpm@11.22.0"
|
|
84
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@collana-solutions/javascript-utils",
|
|
3
|
+
"version": "2.6.1",
|
|
4
|
+
"description": "This is a collection of utilities that we have created to help with our development process.",
|
|
5
|
+
"homepage": "https://github.com/collana-solutions/javascript-utils#readme",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/collana-solutions/javascript-utils"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "collana solutions AG",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"exports": {
|
|
14
|
+
"./package.json": "./package.json",
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/src/index.d.ts",
|
|
17
|
+
"import": "./dist/index.modern.js",
|
|
18
|
+
"require": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"module": "dist/index.modern.js",
|
|
23
|
+
"source": "src/index.ts",
|
|
24
|
+
"jsnext:main": "dist/index.modern.js",
|
|
25
|
+
"types": "dist/src/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"date-fns": "^2.30.0",
|
|
31
|
+
"uuid": "^11.1.1"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@changesets/changelog-github": "^1.0.1",
|
|
35
|
+
"@changesets/cli": "^3.0.3",
|
|
36
|
+
"@jest/types": "^29.6.1",
|
|
37
|
+
"@neolution-ch/eslint-config-neolution": "^2.1.0",
|
|
38
|
+
"@rollup/plugin-commonjs": "^24.1.0",
|
|
39
|
+
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
40
|
+
"@rollup/plugin-terser": "^0.4.1",
|
|
41
|
+
"@types/jest": "^29.5.3",
|
|
42
|
+
"@types/node": "^18.16.3",
|
|
43
|
+
"@types/rollup-plugin-peer-deps-external": "^2.2.5",
|
|
44
|
+
"concurrently": "^8.0.1",
|
|
45
|
+
"cross-env": "^7.0.3",
|
|
46
|
+
"eslint": "^9.24.0",
|
|
47
|
+
"jest": "^29.6.1",
|
|
48
|
+
"jest-localstorage-mock": "^2.4.26",
|
|
49
|
+
"jiti": "^2.4.2",
|
|
50
|
+
"nodemon": "^2.0.22",
|
|
51
|
+
"pkg-pr-new": "^0.0.93",
|
|
52
|
+
"prettier": "^3.5.3",
|
|
53
|
+
"rollup": "^3.21.4",
|
|
54
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
55
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
56
|
+
"ts-jest": "^29.1.1",
|
|
57
|
+
"ts-node": "^10.9.2",
|
|
58
|
+
"typescript": "^5.1.6",
|
|
59
|
+
"yalc": "^1.0.0-pre.53"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18"
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public",
|
|
66
|
+
"registry": "https://registry.npmjs.org"
|
|
67
|
+
},
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "rollup -c --configPlugin rollup-plugin-typescript2",
|
|
70
|
+
"lint": "eslint --cache",
|
|
71
|
+
"prepare-pr": "pnpm exec prettier . --write && pnpm run lint && pnpm run build && pnpm run test",
|
|
72
|
+
"prettier-check": "prettier --check .",
|
|
73
|
+
"prettier-write": "prettier --write .",
|
|
74
|
+
"start": "rollup -c -w",
|
|
75
|
+
"test": "cross-env TZ=Europe/Zurich jest",
|
|
76
|
+
"start-all": "concurrently \"pnpm run start\" \"pnpm run start-yalc\"",
|
|
77
|
+
"start-yalc": "nodemon --watch dist -x \"yalc push\"",
|
|
78
|
+
"changeset": "changeset",
|
|
79
|
+
"version-packages": "changeset version",
|
|
80
|
+
"release": "changeset publish"
|
|
81
|
+
}
|
|
82
|
+
}
|