@dereekb/util 9.24.17 → 9.24.19
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/CHANGELOG.md +8 -0
- package/fetch/CHANGELOG.md +8 -0
- package/fetch/package.json +2 -2
- package/package.json +1 -1
- package/src/lib/contact/phone.d.ts +68 -0
- package/src/lib/contact/phone.js +62 -1
- package/src/lib/contact/phone.js.map +1 -1
- package/src/lib/string/replace.d.ts +68 -3
- package/src/lib/string/replace.js +98 -6
- package/src/lib/string/replace.js.map +1 -1
- package/src/lib/string/url.d.ts +9 -2
- package/src/lib/string/url.js +22 -1
- package/src/lib/string/url.js.map +1 -1
- package/src/lib/value/vector.d.ts +13 -1
- package/src/lib/value/vector.js +20 -1
- package/src/lib/value/vector.js.map +1 -1
- package/test/CHANGELOG.md +8 -0
- package/test/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.24.19](https://github.com/dereekb/dbx-components/compare/v9.24.18-dev...v9.24.19) (2023-07-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [9.24.18](https://github.com/dereekb/dbx-components/compare/v9.24.17-dev...v9.24.18) (2023-07-30)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [9.24.17](https://github.com/dereekb/dbx-components/compare/v9.24.16-dev...v9.24.17) (2023-07-24)
|
|
6
14
|
|
|
7
15
|
|
package/fetch/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.24.19](https://github.com/dereekb/dbx-components/compare/v9.24.18-dev...v9.24.19) (2023-07-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [9.24.18](https://github.com/dereekb/dbx-components/compare/v9.24.17-dev...v9.24.18) (2023-07-30)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [9.24.17](https://github.com/dereekb/dbx-components/compare/v9.24.16-dev...v9.24.17) (2023-07-24)
|
|
6
14
|
|
|
7
15
|
|
package/fetch/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/fetch",
|
|
3
|
-
"version": "9.24.
|
|
3
|
+
"version": "9.24.19",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"types": "./src/index.d.ts",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"peerDependencies": {
|
|
8
|
-
"@dereekb/util": "9.24.
|
|
8
|
+
"@dereekb/util": "9.24.19",
|
|
9
9
|
"lodash.isequal": "^4.5.0",
|
|
10
10
|
"make-error": "^1.3.0",
|
|
11
11
|
"class-validator": "^0.13.2",
|
package/package.json
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
import { Maybe } from '../value/maybe.type';
|
|
1
2
|
/**
|
|
2
3
|
* Phone number string input. No format specified.
|
|
4
|
+
*
|
|
5
|
+
* Examples:
|
|
6
|
+
* - 4567890
|
|
7
|
+
* - 123-456-7890
|
|
8
|
+
* - (123) 456-7890
|
|
9
|
+
* - 1234567890
|
|
10
|
+
* - +1234567890
|
|
11
|
+
* - +1-555-555-5555
|
|
12
|
+
* - 2345678;ext=123
|
|
3
13
|
*/
|
|
4
14
|
export declare type PhoneNumber = string;
|
|
15
|
+
/**
|
|
16
|
+
* 1-6 digit extension number
|
|
17
|
+
*/
|
|
18
|
+
export declare type PhoneExtensionNumber = string;
|
|
5
19
|
/**
|
|
6
20
|
* E.164 Standardized Phone Number. Always starts with a +
|
|
7
21
|
*
|
|
@@ -14,3 +28,57 @@ export declare type E164PhoneNumber = `+${PhoneNumber}`;
|
|
|
14
28
|
* Requires the + to be provided.
|
|
15
29
|
*/
|
|
16
30
|
export declare const E164PHONE_NUMBER_REGEX: RegExp;
|
|
31
|
+
/**
|
|
32
|
+
* Returns true if the input phone number is a valid E164PHONE_NUMBER_REGEX value.
|
|
33
|
+
*
|
|
34
|
+
* @param input
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export declare function isE164PhoneNumber(input: string, allowExtension?: boolean): input is E164PhoneNumber;
|
|
38
|
+
/**
|
|
39
|
+
* E.164 Standardized Phone Number with an extension number. Always starts with a +. The extension is separated with a #.
|
|
40
|
+
*
|
|
41
|
+
* https://en.wikipedia.org/wiki/E.164
|
|
42
|
+
*/
|
|
43
|
+
export declare type E164PhoneNumberWithExtension = `+${PhoneNumber}#${PhoneExtensionNumber}`;
|
|
44
|
+
/**
|
|
45
|
+
* E.164 Standardized Phone Number that may have an extension with it.
|
|
46
|
+
*/
|
|
47
|
+
export declare type E164PhoneNumberWithOptionalExtension = E164PhoneNumber | E164PhoneNumberWithExtension;
|
|
48
|
+
/**
|
|
49
|
+
* E164PhoneNumber regex validator with an optional extension.
|
|
50
|
+
*
|
|
51
|
+
* Requires the + to be provided.
|
|
52
|
+
*/
|
|
53
|
+
export declare const E164PHONE_NUMBER_WITH_OPTIONAL_EXTENSION_REGEX: RegExp;
|
|
54
|
+
/**
|
|
55
|
+
* E164PhoneNumber regex validator with an extension.
|
|
56
|
+
*
|
|
57
|
+
* Requires the + to be provided.
|
|
58
|
+
*/
|
|
59
|
+
export declare const E164PHONE_NUMBER_WITH_EXTENSION_REGEX: RegExp;
|
|
60
|
+
/**
|
|
61
|
+
* Returns true if the input phone number is a valid E164PHONE_NUMBER_WITH_EXTENSION_REGEX value.
|
|
62
|
+
*
|
|
63
|
+
* @param input
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
export declare function isE164PhoneNumberWithExtension(input: string): input is E164PhoneNumberWithExtension;
|
|
67
|
+
export declare const PHONE_EXTENSION_NUMBER_REGEX: RegExp;
|
|
68
|
+
/**
|
|
69
|
+
* Returns true if the input is a valid phone number extension.
|
|
70
|
+
*
|
|
71
|
+
* @param input
|
|
72
|
+
* @returns
|
|
73
|
+
*/
|
|
74
|
+
export declare function isValidPhoneExtensionNumber(input: string): input is PhoneExtensionNumber;
|
|
75
|
+
/**
|
|
76
|
+
* Removes the extension characters from the input phone number.
|
|
77
|
+
*/
|
|
78
|
+
export declare const removeExtensionFromPhoneNumber: (input: PhoneNumber | E164PhoneNumberWithOptionalExtension) => E164PhoneNumber;
|
|
79
|
+
export interface E164PhoneNumberExtensionPair {
|
|
80
|
+
number: E164PhoneNumber;
|
|
81
|
+
extension?: Maybe<PhoneExtensionNumber>;
|
|
82
|
+
}
|
|
83
|
+
export declare function e164PhoneNumberExtensionPair(input: PhoneNumber | E164PhoneNumberWithOptionalExtension): E164PhoneNumberExtensionPair;
|
|
84
|
+
export declare function e164PhoneNumberFromE164PhoneNumberExtensionPair(input: E164PhoneNumberExtensionPair): E164PhoneNumberWithOptionalExtension;
|
package/src/lib/contact/phone.js
CHANGED
|
@@ -1,10 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.E164PHONE_NUMBER_REGEX = void 0;
|
|
3
|
+
exports.e164PhoneNumberFromE164PhoneNumberExtensionPair = exports.e164PhoneNumberExtensionPair = exports.removeExtensionFromPhoneNumber = exports.isValidPhoneExtensionNumber = exports.PHONE_EXTENSION_NUMBER_REGEX = exports.isE164PhoneNumberWithExtension = exports.E164PHONE_NUMBER_WITH_EXTENSION_REGEX = exports.E164PHONE_NUMBER_WITH_OPTIONAL_EXTENSION_REGEX = exports.isE164PhoneNumber = exports.E164PHONE_NUMBER_REGEX = void 0;
|
|
4
|
+
const replace_1 = require("../string/replace");
|
|
4
5
|
/**
|
|
5
6
|
* E164PhoneNumber regex validator.
|
|
6
7
|
*
|
|
7
8
|
* Requires the + to be provided.
|
|
8
9
|
*/
|
|
9
10
|
exports.E164PHONE_NUMBER_REGEX = /^\+[1-9]\d{1,14}$/;
|
|
11
|
+
/**
|
|
12
|
+
* Returns true if the input phone number is a valid E164PHONE_NUMBER_REGEX value.
|
|
13
|
+
*
|
|
14
|
+
* @param input
|
|
15
|
+
* @returns
|
|
16
|
+
*/
|
|
17
|
+
function isE164PhoneNumber(input, allowExtension = true) {
|
|
18
|
+
return (allowExtension ? exports.E164PHONE_NUMBER_WITH_OPTIONAL_EXTENSION_REGEX : exports.E164PHONE_NUMBER_REGEX).test(input);
|
|
19
|
+
}
|
|
20
|
+
exports.isE164PhoneNumber = isE164PhoneNumber;
|
|
21
|
+
/**
|
|
22
|
+
* E164PhoneNumber regex validator with an optional extension.
|
|
23
|
+
*
|
|
24
|
+
* Requires the + to be provided.
|
|
25
|
+
*/
|
|
26
|
+
exports.E164PHONE_NUMBER_WITH_OPTIONAL_EXTENSION_REGEX = /^\+[1-9]\d{1,14}(#\d{1,6})?$/;
|
|
27
|
+
/**
|
|
28
|
+
* E164PhoneNumber regex validator with an extension.
|
|
29
|
+
*
|
|
30
|
+
* Requires the + to be provided.
|
|
31
|
+
*/
|
|
32
|
+
exports.E164PHONE_NUMBER_WITH_EXTENSION_REGEX = /^\+[1-9]\d{1,14}(#\d{1,6})$/;
|
|
33
|
+
/**
|
|
34
|
+
* Returns true if the input phone number is a valid E164PHONE_NUMBER_WITH_EXTENSION_REGEX value.
|
|
35
|
+
*
|
|
36
|
+
* @param input
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
function isE164PhoneNumberWithExtension(input) {
|
|
40
|
+
return exports.E164PHONE_NUMBER_WITH_EXTENSION_REGEX.test(input);
|
|
41
|
+
}
|
|
42
|
+
exports.isE164PhoneNumberWithExtension = isE164PhoneNumberWithExtension;
|
|
43
|
+
exports.PHONE_EXTENSION_NUMBER_REGEX = /^\d{1,6}$/;
|
|
44
|
+
/**
|
|
45
|
+
* Returns true if the input is a valid phone number extension.
|
|
46
|
+
*
|
|
47
|
+
* @param input
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
function isValidPhoneExtensionNumber(input) {
|
|
51
|
+
return exports.PHONE_EXTENSION_NUMBER_REGEX.test(input);
|
|
52
|
+
}
|
|
53
|
+
exports.isValidPhoneExtensionNumber = isValidPhoneExtensionNumber;
|
|
54
|
+
/**
|
|
55
|
+
* Removes the extension characters from the input phone number.
|
|
56
|
+
*/
|
|
57
|
+
exports.removeExtensionFromPhoneNumber = (0, replace_1.removeCharactersAfterFirstCharacterOccurenceFunction)('#');
|
|
58
|
+
const e164PhoneNumberExtensionPairSplitterFunction = (0, replace_1.splitStringAtFirstCharacterOccurenceFunction)('#');
|
|
59
|
+
function e164PhoneNumberExtensionPair(input) {
|
|
60
|
+
const split = e164PhoneNumberExtensionPairSplitterFunction(input);
|
|
61
|
+
return {
|
|
62
|
+
number: split[0],
|
|
63
|
+
extension: split[1]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
exports.e164PhoneNumberExtensionPair = e164PhoneNumberExtensionPair;
|
|
67
|
+
function e164PhoneNumberFromE164PhoneNumberExtensionPair(input) {
|
|
68
|
+
return input.extension ? `${input.number}#${input.extension}` : input.number;
|
|
69
|
+
}
|
|
70
|
+
exports.e164PhoneNumberFromE164PhoneNumberExtensionPair = e164PhoneNumberFromE164PhoneNumberExtensionPair;
|
|
10
71
|
//# sourceMappingURL=phone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phone.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/contact/phone.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"phone.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/contact/phone.ts"],"names":[],"mappings":";;;AAAA,+CAAuI;AA6BvI;;;;GAIG;AACU,QAAA,sBAAsB,GAAG,mBAAmB,CAAC;AAE1D;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,KAAa,EAAE,cAAc,GAAG,IAAI;IACpE,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
import { Maybe } from '../value/maybe.type';
|
|
2
3
|
import { MapSameFunction } from '../value/map';
|
|
3
4
|
export declare type ReplaceStringsFunction = MapSameFunction<string>;
|
|
4
5
|
export interface ReplaceStringsConfig {
|
|
@@ -28,6 +29,70 @@ export declare function findStringsRegexString(find: ArrayOrValue<string>): stri
|
|
|
28
29
|
* @param input
|
|
29
30
|
*/
|
|
30
31
|
export declare function escapeStringForRegex(input: string): string;
|
|
31
|
-
export declare type FindAllCharacterOccurencesFunction = (input: string) => number[];
|
|
32
|
+
export declare type FindAllCharacterOccurencesFunction = (input: string, max?: Maybe<number>) => number[];
|
|
32
33
|
export declare function findAllCharacterOccurencesFunction(characterSet: Set<string>): FindAllCharacterOccurencesFunction;
|
|
33
|
-
|
|
34
|
+
/**
|
|
35
|
+
* First all occurences of the characters from the set in the input string.
|
|
36
|
+
*
|
|
37
|
+
* @param set
|
|
38
|
+
* @param input
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
export declare function findAllCharacterOccurences(set: Set<string>, input: string, max?: number): number[];
|
|
42
|
+
/**
|
|
43
|
+
* First the first occurence of a character from the set in the input string.
|
|
44
|
+
*
|
|
45
|
+
* @param set
|
|
46
|
+
* @param input
|
|
47
|
+
* @returns
|
|
48
|
+
*/
|
|
49
|
+
export declare function findFirstCharacterOccurence(set: Set<string>, input: string): Maybe<number>;
|
|
50
|
+
export declare type SplitStringAtFirstCharacterOccurenceFunction = (input: string) => [string, string | undefined];
|
|
51
|
+
/**
|
|
52
|
+
* Splits the string into two parts at the first occurence of a string or any string in the set.
|
|
53
|
+
*
|
|
54
|
+
* @param set
|
|
55
|
+
* @param input
|
|
56
|
+
*/
|
|
57
|
+
export declare function splitStringAtFirstCharacterOccurenceFunction(splitAt: string | Set<string>): SplitStringAtFirstCharacterOccurenceFunction;
|
|
58
|
+
export declare function splitStringAtFirstCharacterOccurence(input: string, splitAt: string | Set<string>): [string, string | undefined];
|
|
59
|
+
/**
|
|
60
|
+
* Keeps all characters from the input string after the first character occurence pre-determined by the function.
|
|
61
|
+
*
|
|
62
|
+
* If no trigger characters exist, returns an empty string.
|
|
63
|
+
*/
|
|
64
|
+
export declare type KeepCharactersAfterFirstCharacterOccurenceFunction = (input: string) => string;
|
|
65
|
+
/**
|
|
66
|
+
* Splits the string into two parts at the first occurence of a string or any string in the set.
|
|
67
|
+
*
|
|
68
|
+
* @param set
|
|
69
|
+
* @param input
|
|
70
|
+
*/
|
|
71
|
+
export declare function keepCharactersAfterFirstCharacterOccurenceFunction(findCharacters: string | Set<string>): KeepCharactersAfterFirstCharacterOccurenceFunction;
|
|
72
|
+
/**
|
|
73
|
+
* Keeps all characters from the input string after the first character occurence from findCharacters input.
|
|
74
|
+
*
|
|
75
|
+
* @param input
|
|
76
|
+
* @param splitAt
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
export declare function keepCharactersAfterFirstCharacterOccurence(input: string, findCharacters: string | Set<string>): string;
|
|
80
|
+
/**
|
|
81
|
+
* Removes all characters from the input string after the first character occurence pre-determined by the function.
|
|
82
|
+
*/
|
|
83
|
+
export declare type RemoveCharactersAfterFirstCharacterOccurenceFunction = (input: string) => string;
|
|
84
|
+
/**
|
|
85
|
+
* Splits the string into two parts at the first occurence of a string or any string in the set.
|
|
86
|
+
*
|
|
87
|
+
* @param set
|
|
88
|
+
* @param input
|
|
89
|
+
*/
|
|
90
|
+
export declare function removeCharactersAfterFirstCharacterOccurenceFunction(findCharacters: string | Set<string>): RemoveCharactersAfterFirstCharacterOccurenceFunction;
|
|
91
|
+
/**
|
|
92
|
+
* Removes all characters from the input string after the first character occurence from findCharacters input.
|
|
93
|
+
*
|
|
94
|
+
* @param input
|
|
95
|
+
* @param splitAt
|
|
96
|
+
* @returns
|
|
97
|
+
*/
|
|
98
|
+
export declare function removeCharactersAfterFirstCharacterOccurence(input: string, findCharacters: string | Set<string>): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findAllCharacterOccurences = exports.findAllCharacterOccurencesFunction = exports.escapeStringForRegex = exports.findStringsRegexString = exports.REGEX_SPECIAL_CHARACTERS_SET = exports.REGEX_SPECIAL_CHARACTERS = exports.replaceStringsFunction = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.removeCharactersAfterFirstCharacterOccurence = exports.removeCharactersAfterFirstCharacterOccurenceFunction = exports.keepCharactersAfterFirstCharacterOccurence = exports.keepCharactersAfterFirstCharacterOccurenceFunction = exports.splitStringAtFirstCharacterOccurence = exports.splitStringAtFirstCharacterOccurenceFunction = exports.findFirstCharacterOccurence = exports.findAllCharacterOccurences = exports.findAllCharacterOccurencesFunction = exports.escapeStringForRegex = exports.findStringsRegexString = exports.REGEX_SPECIAL_CHARACTERS_SET = exports.REGEX_SPECIAL_CHARACTERS = exports.replaceStringsFunction = void 0;
|
|
4
|
+
const array_1 = require("../array/array");
|
|
5
5
|
const char_1 = require("./char");
|
|
6
6
|
function replaceStringsFunction(config) {
|
|
7
7
|
const { replace: replaceInput, replaceWith } = config;
|
|
@@ -18,7 +18,7 @@ exports.REGEX_SPECIAL_CHARACTERS_SET = new Set(exports.REGEX_SPECIAL_CHARACTERS)
|
|
|
18
18
|
* @param find
|
|
19
19
|
*/
|
|
20
20
|
function findStringsRegexString(find) {
|
|
21
|
-
const input = (0,
|
|
21
|
+
const input = (0, array_1.asArray)(find);
|
|
22
22
|
const escapedInput = input.map(escapeStringForRegex);
|
|
23
23
|
return escapedInput.join('|');
|
|
24
24
|
}
|
|
@@ -70,20 +70,112 @@ function escapeStringForRegex(input) {
|
|
|
70
70
|
}
|
|
71
71
|
exports.escapeStringForRegex = escapeStringForRegex;
|
|
72
72
|
function findAllCharacterOccurencesFunction(characterSet) {
|
|
73
|
-
return (input) => {
|
|
73
|
+
return (input, maxToReturn) => {
|
|
74
|
+
const max = maxToReturn !== null && maxToReturn !== void 0 ? maxToReturn : Number.MAX_SAFE_INTEGER;
|
|
74
75
|
const occurrences = [];
|
|
75
76
|
for (let i = 0; i < input.length; i += 1) {
|
|
76
77
|
const char = input[i];
|
|
77
78
|
if (characterSet.has(char)) {
|
|
78
79
|
occurrences.push(i);
|
|
80
|
+
// return if at the max number of occurences
|
|
81
|
+
if (occurrences.length >= max) {
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
return occurrences;
|
|
82
87
|
};
|
|
83
88
|
}
|
|
84
89
|
exports.findAllCharacterOccurencesFunction = findAllCharacterOccurencesFunction;
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
/**
|
|
91
|
+
* First all occurences of the characters from the set in the input string.
|
|
92
|
+
*
|
|
93
|
+
* @param set
|
|
94
|
+
* @param input
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
function findAllCharacterOccurences(set, input, max) {
|
|
98
|
+
return findAllCharacterOccurencesFunction(set)(input, max);
|
|
87
99
|
}
|
|
88
100
|
exports.findAllCharacterOccurences = findAllCharacterOccurences;
|
|
101
|
+
/**
|
|
102
|
+
* First the first occurence of a character from the set in the input string.
|
|
103
|
+
*
|
|
104
|
+
* @param set
|
|
105
|
+
* @param input
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
function findFirstCharacterOccurence(set, input) {
|
|
109
|
+
return findAllCharacterOccurences(set, input, 1)[0];
|
|
110
|
+
}
|
|
111
|
+
exports.findFirstCharacterOccurence = findFirstCharacterOccurence;
|
|
112
|
+
/**
|
|
113
|
+
* Splits the string into two parts at the first occurence of a string or any string in the set.
|
|
114
|
+
*
|
|
115
|
+
* @param set
|
|
116
|
+
* @param input
|
|
117
|
+
*/
|
|
118
|
+
function splitStringAtFirstCharacterOccurenceFunction(splitAt) {
|
|
119
|
+
return (input) => {
|
|
120
|
+
const splitSet = typeof splitAt === 'string' ? new Set([splitAt]) : splitAt;
|
|
121
|
+
const firstOccurence = findFirstCharacterOccurence(splitSet, input);
|
|
122
|
+
let result;
|
|
123
|
+
if (firstOccurence != null) {
|
|
124
|
+
result = (0, char_1.splitStringAtIndex)(input, firstOccurence, false);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
result = [input, undefined];
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
exports.splitStringAtFirstCharacterOccurenceFunction = splitStringAtFirstCharacterOccurenceFunction;
|
|
133
|
+
function splitStringAtFirstCharacterOccurence(input, splitAt) {
|
|
134
|
+
return splitStringAtFirstCharacterOccurenceFunction(splitAt)(input);
|
|
135
|
+
}
|
|
136
|
+
exports.splitStringAtFirstCharacterOccurence = splitStringAtFirstCharacterOccurence;
|
|
137
|
+
/**
|
|
138
|
+
* Splits the string into two parts at the first occurence of a string or any string in the set.
|
|
139
|
+
*
|
|
140
|
+
* @param set
|
|
141
|
+
* @param input
|
|
142
|
+
*/
|
|
143
|
+
function keepCharactersAfterFirstCharacterOccurenceFunction(findCharacters) {
|
|
144
|
+
const splitStringAtFirstCharacterOccurence = splitStringAtFirstCharacterOccurenceFunction(findCharacters);
|
|
145
|
+
return (input) => { var _a; return (_a = splitStringAtFirstCharacterOccurence(input)[1]) !== null && _a !== void 0 ? _a : ''; };
|
|
146
|
+
}
|
|
147
|
+
exports.keepCharactersAfterFirstCharacterOccurenceFunction = keepCharactersAfterFirstCharacterOccurenceFunction;
|
|
148
|
+
/**
|
|
149
|
+
* Keeps all characters from the input string after the first character occurence from findCharacters input.
|
|
150
|
+
*
|
|
151
|
+
* @param input
|
|
152
|
+
* @param splitAt
|
|
153
|
+
* @returns
|
|
154
|
+
*/
|
|
155
|
+
function keepCharactersAfterFirstCharacterOccurence(input, findCharacters) {
|
|
156
|
+
return keepCharactersAfterFirstCharacterOccurenceFunction(findCharacters)(input);
|
|
157
|
+
}
|
|
158
|
+
exports.keepCharactersAfterFirstCharacterOccurence = keepCharactersAfterFirstCharacterOccurence;
|
|
159
|
+
/**
|
|
160
|
+
* Splits the string into two parts at the first occurence of a string or any string in the set.
|
|
161
|
+
*
|
|
162
|
+
* @param set
|
|
163
|
+
* @param input
|
|
164
|
+
*/
|
|
165
|
+
function removeCharactersAfterFirstCharacterOccurenceFunction(findCharacters) {
|
|
166
|
+
const splitStringAtFirstCharacterOccurence = splitStringAtFirstCharacterOccurenceFunction(findCharacters);
|
|
167
|
+
return (input) => splitStringAtFirstCharacterOccurence(input)[0];
|
|
168
|
+
}
|
|
169
|
+
exports.removeCharactersAfterFirstCharacterOccurenceFunction = removeCharactersAfterFirstCharacterOccurenceFunction;
|
|
170
|
+
/**
|
|
171
|
+
* Removes all characters from the input string after the first character occurence from findCharacters input.
|
|
172
|
+
*
|
|
173
|
+
* @param input
|
|
174
|
+
* @param splitAt
|
|
175
|
+
* @returns
|
|
176
|
+
*/
|
|
177
|
+
function removeCharactersAfterFirstCharacterOccurence(input, findCharacters) {
|
|
178
|
+
return removeCharactersAfterFirstCharacterOccurenceFunction(findCharacters)(input);
|
|
179
|
+
}
|
|
180
|
+
exports.removeCharactersAfterFirstCharacterOccurence = removeCharactersAfterFirstCharacterOccurence;
|
|
89
181
|
//# sourceMappingURL=replace.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replace.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/replace.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"replace.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/replace.ts"],"names":[],"mappings":";;;AAAA,0CAAuD;AAGvD,iCAAyE;AAezE,SAAgB,sBAAsB,CAAC,MAA4B;IACjE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACtD,MAAM,kBAAkB,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;IAChE,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;IACzD,OAAO,C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AO,CAAC,CAAC,KAAK,CAAC,CAAC;AACtE,CAAC;AAFD,oFAEC;AASD;;;;;GAKG;AACH,SAAgB,kDAAkD,CAAC,cAAoC;IACrG,MAAM,oCAAoC,GAAG,4CAA4C,CAAC,cAAc,CAAC,CAAC;IAC1G,OAAO,CAAC,KAAa,EAAE,EAAE,WAAC,OAAA,MAAA,oCAAoC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,mCAAI,EAAE,CAAA,EAAA,CAAC;AACjF,CAAC;AAHD,gHAGC;AAED;;;;;;GAMG;AACH,SAAgB,0CAA0C,CAAC,KAAa,EAAE,cAAoC;IAC5G,OAAO,kDAAkD,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,CAAC;AACnF,CAAC;AAFD,gGAEC;AAOD;;;;;GAKG;AACH,SAAgB,oDAAoD,CAAC,cAAoC;IACvG,MAAM,oCAAoC,GAAG,4CAA4C,CAAC,cAAc,CAAC,CAAC;IAC1G,OAAO,CAAC,KAAa,EAAE,EAAE,CAAC,oCAAoC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3E,CAAC;AAHD,oHAGC;AAED;;;;;;GAMG;AACH,SAAgB,4CAA4C,CAAC,KAAa,EAAE,cAAoC;IAC9G,OAAO,oDAAoD,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,CAAC;AACrF,CAAC;AAFD,oGAEC"}
|
package/src/lib/string/url.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EmailAddress } from '../contact/email';
|
|
2
|
-
import { PhoneNumber } from '../contact/phone';
|
|
2
|
+
import { E164PhoneNumberExtensionPair, E164PhoneNumberWithOptionalExtension, PhoneNumber } from '../contact/phone';
|
|
3
3
|
import { IndexRangeInput } from './../value/indexed';
|
|
4
4
|
import { MapFunction } from '../value/map';
|
|
5
5
|
import { Maybe } from '../value/maybe.type';
|
|
@@ -181,4 +181,11 @@ export interface MailToUrl {
|
|
|
181
181
|
}
|
|
182
182
|
export declare type MailToUrlInput = EmailAddress | MailToUrl;
|
|
183
183
|
export declare function mailToUrlString(input: MailToUrlInput): string;
|
|
184
|
-
export declare function telUrlString(phone: PhoneNumber): string;
|
|
184
|
+
export declare function telUrlString(phone: PhoneNumber | E164PhoneNumberWithOptionalExtension): string;
|
|
185
|
+
/**
|
|
186
|
+
* Creates a tel url string for the input E164PhoneNumberExtensionPair.
|
|
187
|
+
*
|
|
188
|
+
* @param pair
|
|
189
|
+
* @returns
|
|
190
|
+
*/
|
|
191
|
+
export declare function telUrlStringForE164PhoneNumberPair(pair: E164PhoneNumberExtensionPair): string;
|
package/src/lib/string/url.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.telUrlString = exports.mailToUrlString = exports.hasHttpPrefix = exports.removeHttpFromUrl = exports.addHttpToUrl = exports.removeWebProtocolPrefix = exports.setWebProtocolPrefix = exports.WEB_PROTOCOL_PREFIX_REGEX = exports.HTTP_OR_HTTPS_REGEX = exports.websiteDomainAndPathPair = exports.websitePathFromWebsiteDomainAndPath = exports.websiteDomainAndPathPairFromWebsiteUrl = exports.websitePathFromWebsiteUrl = exports.fixExtraQueryParameters = exports.websitePathAndQueryPair = exports.isolateWebsitePathFunction = exports.hasWebsiteDomain = exports.WEBSITE_DOMAIN_NAME_REGEX = void 0;
|
|
3
|
+
exports.telUrlStringForE164PhoneNumberPair = exports.telUrlString = exports.mailToUrlString = exports.hasHttpPrefix = exports.removeHttpFromUrl = exports.addHttpToUrl = exports.removeWebProtocolPrefix = exports.setWebProtocolPrefix = exports.WEB_PROTOCOL_PREFIX_REGEX = exports.HTTP_OR_HTTPS_REGEX = exports.websiteDomainAndPathPair = exports.websitePathFromWebsiteDomainAndPath = exports.websiteDomainAndPathPairFromWebsiteUrl = exports.websitePathFromWebsiteUrl = exports.fixExtraQueryParameters = exports.websitePathAndQueryPair = exports.isolateWebsitePathFunction = exports.hasWebsiteDomain = exports.WEBSITE_DOMAIN_NAME_REGEX = void 0;
|
|
4
|
+
const phone_1 = require("../contact/phone");
|
|
4
5
|
const path_1 = require("../path/path");
|
|
5
6
|
const map_1 = require("../value/map");
|
|
6
7
|
const replace_1 = require("./replace");
|
|
@@ -193,7 +194,27 @@ function mailToUrlString(input) {
|
|
|
193
194
|
exports.mailToUrlString = mailToUrlString;
|
|
194
195
|
// MARK: Tel
|
|
195
196
|
function telUrlString(phone) {
|
|
197
|
+
if ((0, phone_1.isE164PhoneNumber)(phone, true)) {
|
|
198
|
+
const pair = (0, phone_1.e164PhoneNumberExtensionPair)(phone);
|
|
199
|
+
return telUrlStringForE164PhoneNumberPair(pair);
|
|
200
|
+
}
|
|
196
201
|
return `tel:${phone}`;
|
|
197
202
|
}
|
|
198
203
|
exports.telUrlString = telUrlString;
|
|
204
|
+
/**
|
|
205
|
+
* Creates a tel url string for the input E164PhoneNumberExtensionPair.
|
|
206
|
+
*
|
|
207
|
+
* @param pair
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
function telUrlStringForE164PhoneNumberPair(pair) {
|
|
211
|
+
// https://stackoverflow.com/questions/9482633/how-do-i-include-extensions-in-the-tel-uri
|
|
212
|
+
if (pair.extension) {
|
|
213
|
+
return `tel:${pair.number};${pair.extension}`;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
return `tel:${pair.number}`;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
exports.telUrlStringForE164PhoneNumberPair = telUrlStringForE164PhoneNumberPair;
|
|
199
220
|
//# sourceMappingURL=url.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/url.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/url.ts"],"names":[],"mappings":";;;AACA,4CAAmN;AAEnN,uCAA4G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,CAAC;AACzC,CAAC;AAFD,sCAEC;AASD,SAAgB,eAAe,CAAC,KAAqB;IACnD,MAAM,MAAM,GAAc,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAC/E,OAAO,UAAU,MAAM,CAAC,KAAK,EAAE,CAAC;AAClC,CAAC;AAHD,0CAGC;AAED,YAAY;AACZ,SAAgB,YAAY,CAAC,KAAyD;IACpF,IAAI,IAAA,yBAAiB,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE;QAClC,MAAM,IAAI,GAAG,IAAA,oCAA4B,EAAC,KAAK,CAAC,CAAC;QACjD,OAAO,kCAAkC,CAAC,IAAI,CAAC,CAAC;KACjD;IAED,OAAO,OAAO,KAAK,EAAE,CAAC;AACxB,CAAC;AAPD,oCAOC;AAED;;;;;GAKG;AACH,SAAgB,kCAAkC,CAAC,IAAkC;IACnF,yFAAyF;IACzF,IAAI,IAAI,CAAC,SAAS,EAAE;QAClB,OAAO,OAAO,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;KAC/C;SAAM;QACL,OAAO,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;KAC7B;AACH,CAAC;AAPD,gFAOC"}
|
|
@@ -4,7 +4,19 @@ export interface Vector {
|
|
|
4
4
|
y: number;
|
|
5
5
|
}
|
|
6
6
|
export declare type VectorTuple = [number, number];
|
|
7
|
-
export declare function
|
|
7
|
+
export declare function isSameVector(a: Maybe<Partial<Vector>>, b: Maybe<Partial<Vector>>): boolean;
|
|
8
|
+
export declare function vectorsAreEqual(a: Partial<Vector>, b: Partial<Vector>): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Function that resizes a vector.
|
|
11
|
+
*/
|
|
12
|
+
export declare type VectorResizeFunction = (input: Vector) => Vector;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a VectorResizeFunction that returns the larger x/y values from the input and the minimum vector.
|
|
15
|
+
*
|
|
16
|
+
* @param min
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export declare function vectorMinimumSizeResizeFunction(minSize: Partial<Vector>): VectorResizeFunction;
|
|
8
20
|
export declare type RectangleOrigin = Vector;
|
|
9
21
|
export declare type TopRightCorner = Vector;
|
|
10
22
|
export declare type BottomLeftCorner = Vector;
|
package/src/lib/value/vector.js
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOverlappingRectangle = exports.rectangleOverlapsRectangle = exports.vectorsAreEqual = void 0;
|
|
3
|
+
exports.getOverlappingRectangle = exports.rectangleOverlapsRectangle = exports.vectorMinimumSizeResizeFunction = exports.vectorsAreEqual = exports.isSameVector = void 0;
|
|
4
|
+
function isSameVector(a, b) {
|
|
5
|
+
return a && b ? vectorsAreEqual(a, b) : a === b;
|
|
6
|
+
}
|
|
7
|
+
exports.isSameVector = isSameVector;
|
|
4
8
|
function vectorsAreEqual(a, b) {
|
|
5
9
|
return a.x === b.x && a.y === b.y;
|
|
6
10
|
}
|
|
7
11
|
exports.vectorsAreEqual = vectorsAreEqual;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a VectorResizeFunction that returns the larger x/y values from the input and the minimum vector.
|
|
14
|
+
*
|
|
15
|
+
* @param min
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
function vectorMinimumSizeResizeFunction(minSize) {
|
|
19
|
+
return (input) => {
|
|
20
|
+
return {
|
|
21
|
+
x: minSize.x != null ? Math.max(input.x, minSize.x) : input.x,
|
|
22
|
+
y: minSize.y != null ? Math.max(input.y, minSize.y) : input.y
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.vectorMinimumSizeResizeFunction = vectorMinimumSizeResizeFunction;
|
|
8
27
|
/**
|
|
9
28
|
* Returns true if the input vector overlaps another.
|
|
10
29
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/vector.ts"],"names":[],"mappings":";;;AASA,SAAgB,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"vector.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/vector.ts"],"names":[],"mappings":";;;AASA,SAAgB,YAAY,CAAC,CAAyB,EAAE,CAAyB;IAC/E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAFD,oCAEC;AAED,SAAgB,eAAe,CAAC,CAAkB,EAAE,CAAkB;IACpE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAFD,0CAEC;AAOD;;;;;GAKG;AACH,SAAgB,+BAA+B,CAAC,OAAwB;IACtE,OAAO,CAAC,KAAa,EAAE,EAAE;QACvB,OAAO;YACL,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;YAC7D,CAAC,EAAE,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SAC9D,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAPD,0EAOC;AAiBD;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAC,CAAY,EAAE,CAAY;IACnE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAA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C,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEpC,qBAAqB;IACrB,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QACtB,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,QAAQ,GAAmB;QAC/B,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,EAAE;KACN,CAAC;IAEF,MAAM,UAAU,GAAqB;QACnC,CAAC,EAAE,EAAE;QACL,CAAC,EAAE,EAAE;KACN,CAAC;IAEF,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC;AAC1C,CAAC;AAtBD,0DAsBC"}
|
package/test/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [9.24.19](https://github.com/dereekb/dbx-components/compare/v9.24.18-dev...v9.24.19) (2023-07-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
## [9.24.18](https://github.com/dereekb/dbx-components/compare/v9.24.17-dev...v9.24.18) (2023-07-30)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
5
13
|
## [9.24.17](https://github.com/dereekb/dbx-components/compare/v9.24.16-dev...v9.24.17) (2023-07-24)
|
|
6
14
|
|
|
7
15
|
|
package/test/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/util/test",
|
|
3
|
-
"version": "9.24.
|
|
3
|
+
"version": "9.24.19",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
7
|
"dependencies": {},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"@dereekb/util": "9.24.
|
|
9
|
+
"@dereekb/util": "9.24.19",
|
|
10
10
|
"lodash.isequal": "^4.5.0",
|
|
11
11
|
"make-error": "^1.3.0",
|
|
12
12
|
"class-validator": "^0.13.2",
|