@dereekb/util 8.8.1 → 8.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/package.json +1 -1
  3. package/src/lib/array/array.string.d.ts +8 -20
  4. package/src/lib/array/array.string.js +14 -13
  5. package/src/lib/array/array.string.js.map +1 -1
  6. package/src/lib/error/error.d.ts +4 -0
  7. package/src/lib/error/error.js +18 -1
  8. package/src/lib/error/error.js.map +1 -1
  9. package/src/lib/index.d.ts +3 -1
  10. package/src/lib/index.js +3 -1
  11. package/src/lib/index.js.map +1 -1
  12. package/src/lib/nodejs/index.d.ts +1 -0
  13. package/src/lib/nodejs/index.js +5 -0
  14. package/src/lib/nodejs/index.js.map +1 -0
  15. package/src/lib/nodejs/stream.d.ts +22 -0
  16. package/src/lib/nodejs/stream.js +34 -0
  17. package/src/lib/nodejs/stream.js.map +1 -0
  18. package/src/lib/number/number.d.ts +4 -0
  19. package/src/lib/number/number.js.map +1 -1
  20. package/src/lib/number/round.d.ts +36 -1
  21. package/src/lib/number/round.js +51 -1
  22. package/src/lib/number/round.js.map +1 -1
  23. package/src/lib/path/index.d.ts +1 -0
  24. package/src/lib/path/index.js +5 -0
  25. package/src/lib/path/index.js.map +1 -0
  26. package/src/lib/path/path.d.ts +157 -0
  27. package/src/lib/path/path.js +226 -0
  28. package/src/lib/path/path.js.map +1 -0
  29. package/src/lib/promise/callback.d.ts +4 -0
  30. package/src/lib/promise/callback.js +21 -0
  31. package/src/lib/promise/callback.js.map +1 -0
  32. package/src/lib/promise/index.d.ts +1 -0
  33. package/src/lib/promise/index.js +1 -0
  34. package/src/lib/promise/index.js.map +1 -1
  35. package/src/lib/string/char.d.ts +34 -0
  36. package/src/lib/string/char.js +66 -0
  37. package/src/lib/string/char.js.map +1 -0
  38. package/src/lib/string/index.d.ts +4 -0
  39. package/src/lib/string/index.js +8 -0
  40. package/src/lib/string/index.js.map +1 -0
  41. package/src/lib/string/replace.d.ts +30 -0
  42. package/src/lib/string/replace.js +78 -0
  43. package/src/lib/string/replace.js.map +1 -0
  44. package/src/lib/{string.d.ts → string/string.d.ts} +2 -2
  45. package/src/lib/{string.js → string/string.js} +0 -0
  46. package/src/lib/string/string.js.map +1 -0
  47. package/src/lib/string/transform.d.ts +24 -0
  48. package/src/lib/string/transform.js +43 -0
  49. package/src/lib/string/transform.js.map +1 -0
  50. package/src/lib/value/index.d.ts +1 -0
  51. package/src/lib/value/index.js +1 -0
  52. package/src/lib/value/index.js.map +1 -1
  53. package/src/lib/value/map.d.ts +29 -1
  54. package/src/lib/value/map.js +42 -1
  55. package/src/lib/value/map.js.map +1 -1
  56. package/src/lib/value/point.d.ts +192 -0
  57. package/src/lib/value/point.js +191 -0
  58. package/src/lib/value/point.js.map +1 -0
  59. package/test/CHANGELOG.md +12 -0
  60. package/test/package.json +2 -2
  61. package/src/lib/string.js.map +0 -1
@@ -0,0 +1,226 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.slashPathInvalidError = exports.mergeSlashPaths = exports.slashPathFactory = exports.slashPathValidationFactory = exports.replaceInvalidFilePathTypeSeparatorsInSlashPathFunction = exports.replaceInvalidFilePathTypeSeparatorsInSlashPath = exports.removeTrailingFileTypeSeparators = exports.replaceMultipleFilePathsInSlashPath = exports.fixMultiSlashesInSlashPath = exports.toAbsoluteSlashPathStartType = exports.toRelativeSlashPathStartType = exports.ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = exports.ALL_DOUBLE_SLASHES_REGEX = exports.ALL_SLASHES_REGEX = exports.TRAILING_FILE_TYPE_SEPARATORS_REGEX = exports.TRAILING_SLASHES_REGEX = exports.LEADING_SLASHES_REGEX = exports.slashPathStartTypeFactory = exports.slashPathParts = exports.slashPathName = exports.isValidSlashPath = exports.isSlashPathFolder = exports.isSlashPathFile = exports.slashPathType = exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT = exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = exports.SLASH_PATH_FILE_TYPE_SEPARATOR = exports.SLASH_PATH_SEPARATOR = void 0;
4
+ const map_1 = require("../value/map");
5
+ const array_1 = require("../array/array");
6
+ const string_1 = require("../string");
7
+ const value_1 = require("../value");
8
+ exports.SLASH_PATH_SEPARATOR = '/';
9
+ exports.SLASH_PATH_FILE_TYPE_SEPARATOR = '.';
10
+ exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS = ['#', '[', ']', '*', '?'];
11
+ /**
12
+ * Default replacement character for illegal characters.
13
+ */
14
+ exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT = '_';
15
+ /**
16
+ * Returns the SlashPathType for the input.
17
+ *
18
+ * @param input
19
+ * @returns
20
+ */
21
+ function slashPathType(input) {
22
+ const dotCount = input.split(exports.SLASH_PATH_FILE_TYPE_SEPARATOR, 2).length;
23
+ let type;
24
+ switch (dotCount) {
25
+ case 0:
26
+ if (input.length === 0) {
27
+ type = 'invalid';
28
+ }
29
+ else {
30
+ const lastValue = input[input.length - 1];
31
+ if (lastValue === exports.SLASH_PATH_SEPARATOR) {
32
+ type = 'folder';
33
+ }
34
+ else {
35
+ type = 'file';
36
+ }
37
+ }
38
+ break;
39
+ case 1:
40
+ type = 'file';
41
+ break;
42
+ default:
43
+ type = 'invalid';
44
+ break;
45
+ }
46
+ return type;
47
+ }
48
+ exports.slashPathType = slashPathType;
49
+ function isSlashPathFile(input) {
50
+ const type = slashPathType(input);
51
+ return type === 'file' || type === 'typedfile';
52
+ }
53
+ exports.isSlashPathFile = isSlashPathFile;
54
+ function isSlashPathFolder(input) {
55
+ return slashPathType(input) === 'folder';
56
+ }
57
+ exports.isSlashPathFolder = isSlashPathFolder;
58
+ function isValidSlashPath(input) {
59
+ return slashPathType(input) !== 'invalid';
60
+ }
61
+ exports.isValidSlashPath = isValidSlashPath;
62
+ /**
63
+ * Returns the last part of the slash path.
64
+ *
65
+ * @param slashPath
66
+ */
67
+ function slashPathName(slashPath) {
68
+ const parts = slashPathParts(slashPath);
69
+ return parts[parts.length - 1];
70
+ }
71
+ exports.slashPathName = slashPathName;
72
+ /**
73
+ * Returns each section of a SlashPath
74
+ *
75
+ * @param slashPath
76
+ * @returns
77
+ */
78
+ function slashPathParts(slashPath) {
79
+ return slashPath.split(exports.SLASH_PATH_SEPARATOR).filter((x) => Boolean(x));
80
+ }
81
+ exports.slashPathParts = slashPathParts;
82
+ function slashPathStartTypeFactory(type) {
83
+ let fn;
84
+ switch (type) {
85
+ case 'relative':
86
+ fn = toRelativeSlashPathStartType;
87
+ break;
88
+ case 'absolute':
89
+ fn = toAbsoluteSlashPathStartType;
90
+ break;
91
+ case 'any':
92
+ fn = (0, value_1.mapIdentityFunction)();
93
+ break;
94
+ }
95
+ return fn;
96
+ }
97
+ exports.slashPathStartTypeFactory = slashPathStartTypeFactory;
98
+ exports.LEADING_SLASHES_REGEX = /^\/+/;
99
+ exports.TRAILING_SLASHES_REGEX = /\/+$/;
100
+ exports.TRAILING_FILE_TYPE_SEPARATORS_REGEX = /\.+$/;
101
+ exports.ALL_SLASHES_REGEX = /\/+/g;
102
+ exports.ALL_DOUBLE_SLASHES_REGEX = /\/{2,}/g;
103
+ exports.ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
104
+ function toRelativeSlashPathStartType(input) {
105
+ // remove all leading slashes
106
+ return input.replace(exports.LEADING_SLASHES_REGEX, '');
107
+ }
108
+ exports.toRelativeSlashPathStartType = toRelativeSlashPathStartType;
109
+ /**
110
+ *
111
+ * @param input
112
+ * @returns
113
+ */
114
+ function toAbsoluteSlashPathStartType(input) {
115
+ // add a leading slash, and remove any multiple slashes if provided
116
+ return input.startsWith(exports.SLASH_PATH_SEPARATOR) ? input.replace(exports.LEADING_SLASHES_REGEX, exports.SLASH_PATH_SEPARATOR) : `${exports.SLASH_PATH_SEPARATOR}${input}`;
117
+ }
118
+ exports.toAbsoluteSlashPathStartType = toAbsoluteSlashPathStartType;
119
+ function fixMultiSlashesInSlashPath(input) {
120
+ return input.replace(exports.ALL_DOUBLE_SLASHES_REGEX, exports.SLASH_PATH_SEPARATOR);
121
+ }
122
+ exports.fixMultiSlashesInSlashPath = fixMultiSlashesInSlashPath;
123
+ function replaceMultipleFilePathsInSlashPath(input) {
124
+ return input.replace(exports.ALL_DOUBLE_SLASHES_REGEX, exports.SLASH_PATH_SEPARATOR);
125
+ }
126
+ exports.replaceMultipleFilePathsInSlashPath = replaceMultipleFilePathsInSlashPath;
127
+ function removeTrailingFileTypeSeparators(input) {
128
+ return input.replace(exports.TRAILING_FILE_TYPE_SEPARATORS_REGEX, '');
129
+ }
130
+ exports.removeTrailingFileTypeSeparators = removeTrailingFileTypeSeparators;
131
+ /**
132
+ * Replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
133
+ *
134
+ * @param input
135
+ * @param replaceWith
136
+ * @returns
137
+ */
138
+ function replaceInvalidFilePathTypeSeparatorsInSlashPath(input, replaceWith) {
139
+ return replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceWith)(input);
140
+ }
141
+ exports.replaceInvalidFilePathTypeSeparatorsInSlashPath = replaceInvalidFilePathTypeSeparatorsInSlashPath;
142
+ /**
143
+ * Creates a function that replaces all extra and invalidate FilePathTypeSeparator values from the SlashPath, returning a valid SlashPath.
144
+ *
145
+ * @param input
146
+ * @param replaceWith
147
+ * @returns
148
+ */
149
+ function replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceWith = exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT) {
150
+ return (input) => {
151
+ const endsOnFileTypeSeparator = input[input.length - 1] === exports.SLASH_PATH_FILE_TYPE_SEPARATOR;
152
+ const inputToEvaluate = endsOnFileTypeSeparator ? removeTrailingFileTypeSeparators(input) : input;
153
+ const { first, last, occurences } = (0, string_1.firstAndLastCharacterOccurrence)(inputToEvaluate, exports.SLASH_PATH_FILE_TYPE_SEPARATOR);
154
+ let fixedPath;
155
+ switch (occurences) {
156
+ case 0:
157
+ fixedPath = inputToEvaluate;
158
+ break;
159
+ case 1:
160
+ const lastSlashPosition = inputToEvaluate.lastIndexOf('/');
161
+ if (lastSlashPosition === -1 || lastSlashPosition < last) {
162
+ // valid path
163
+ fixedPath = inputToEvaluate;
164
+ }
165
+ else {
166
+ // the dot occurs before another slash, so we should replace it
167
+ fixedPath = (0, string_1.replaceCharacterAtIndexWith)(inputToEvaluate, last, replaceWith);
168
+ }
169
+ break;
170
+ default:
171
+ const [head, tail] = (0, string_1.splitStringAtIndex)(inputToEvaluate, last, true);
172
+ const headWithReplacedSeparators = head.replace(exports.ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX, replaceWith);
173
+ fixedPath = headWithReplacedSeparators + tail;
174
+ break;
175
+ }
176
+ return fixedPath;
177
+ };
178
+ }
179
+ exports.replaceInvalidFilePathTypeSeparatorsInSlashPathFunction = replaceInvalidFilePathTypeSeparatorsInSlashPathFunction;
180
+ function slashPathValidationFactory(config) {
181
+ const { illegalStrings = exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS, replaceIllegalCharacters: inputReplaceIllegalCharacters = true, replaceIllegalDots: inputReplaceIllegalDots = true, throwError } = config !== null && config !== void 0 ? config : {};
182
+ const fns = [];
183
+ const replaceIllegalCharacters = typeof inputReplaceIllegalCharacters === 'string' ? inputReplaceIllegalCharacters : exports.DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT;
184
+ if (inputReplaceIllegalCharacters != null) {
185
+ fns.push((0, string_1.replaceStringsFunction)({
186
+ replace: illegalStrings,
187
+ replaceWith: replaceIllegalCharacters
188
+ }));
189
+ }
190
+ if (inputReplaceIllegalDots != null) {
191
+ const replaceIllegalDotsWith = typeof inputReplaceIllegalDots === 'string' ? inputReplaceIllegalDots : replaceIllegalCharacters;
192
+ fns.push(replaceInvalidFilePathTypeSeparatorsInSlashPathFunction(replaceIllegalDotsWith));
193
+ }
194
+ if (throwError === true || !(inputReplaceIllegalCharacters || inputReplaceIllegalDots)) {
195
+ fns.push((x) => {
196
+ if (!isValidSlashPath(x)) {
197
+ throw slashPathInvalidError();
198
+ }
199
+ return x;
200
+ });
201
+ }
202
+ return (0, map_1.chainMapSameFunctions)(fns);
203
+ }
204
+ exports.slashPathValidationFactory = slashPathValidationFactory;
205
+ function slashPathFactory(config) {
206
+ const { startType: type = 'any', basePath: inputBasePaths, validate = true } = config !== null && config !== void 0 ? config : {};
207
+ const basePath = inputBasePaths ? mergeSlashPaths((0, array_1.asArray)(inputBasePaths)) : '';
208
+ const typeFactory = slashPathStartTypeFactory(type);
209
+ const validationFactory = validate ? (typeof validate === 'boolean' ? slashPathValidationFactory() : slashPathValidationFactory(validate)) : null;
210
+ const finalizeFn = (0, value_1.chainMapFunction)(typeFactory, validationFactory);
211
+ return (paths) => {
212
+ const merged = mergeSlashPaths((0, array_1.mergeArrayOrValueIntoArray)([basePath], paths));
213
+ return finalizeFn(merged);
214
+ };
215
+ }
216
+ exports.slashPathFactory = slashPathFactory;
217
+ function mergeSlashPaths(paths) {
218
+ const merge = paths.filter((x) => Boolean(x)).join(exports.SLASH_PATH_SEPARATOR);
219
+ return fixMultiSlashesInSlashPath(merge);
220
+ }
221
+ exports.mergeSlashPaths = mergeSlashPaths;
222
+ function slashPathInvalidError() {
223
+ return new Error('The slashPath is invalid.');
224
+ }
225
+ exports.slashPathInvalidError = slashPathInvalidError;
226
+ //# sourceMappingURL=path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/path/path.ts"],"names":[],"mappings":";;;AAAA,sCAAsE;AACtE,0CAAmF;AACnF,sCAAqI;AACrI,oCAAiE;AAGpD,QAAA,oBAAoB,GAAG,GAAG,CAAC;AAC3B,QAAA,8BAA8B,GAAG,GAAG,CAAC;AAKrC,QAAA,qCAAqC,GAAG,CAAC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MAAM,MAAM,GAAG,eAAe,CAAC,IAAA,kCAA0B,EAAC,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;QAC9E,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC;AAXD,4CAWC;AAED,SAAgB,eAAe,CAAC,KAAkB;IAChD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,4BAAoB,CAAC,CAAC;IACzE,OAAO,0BAA0B,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC;AAHD,0CAGC;AAED,SAAgB,qBAAqB;IACnC,OAAO,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAChD,CAAC;AAFD,sDAEC"}
@@ -0,0 +1,4 @@
1
+ import { Maybe } from '../value/maybe.type';
2
+ export declare type PromiseCallback = (err?: Maybe<Error>) => void;
3
+ export declare type UsePromiseCallback = (cb: PromiseCallback) => void;
4
+ export declare function useCallback(use: UsePromiseCallback): Promise<void>;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCallback = void 0;
4
+ const tslib_1 = require("tslib");
5
+ function useCallback(use) {
6
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
7
+ return new Promise((resolve, reject) => {
8
+ const callback = (err) => {
9
+ if (err != null) {
10
+ reject(err);
11
+ }
12
+ else {
13
+ resolve();
14
+ }
15
+ };
16
+ use(callback);
17
+ });
18
+ });
19
+ }
20
+ exports.useCallback = useCallback;
21
+ //# sourceMappingURL=callback.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callback.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/promise/callback.ts"],"names":[],"mappings":";;;;AAKA,SAAsB,WAAW,CAAC,GAAuB;;QACvD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,QAAQ,GAAG,CAAC,GAAkB,EAAE,EAAE;gBACtC,IAAI,GAAG,IAAI,IAAI,EAAE;oBACf,MAAM,CAAC,GAAG,CAAC,CAAC;iBACb;qBAAM;oBACL,OAAO,EAAE,CAAC;iBACX;YACH,CAAC,CAAC;YAEF,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;CAAA;AAZD,kCAYC"}
@@ -1,3 +1,4 @@
1
+ export * from './callback';
1
2
  export * from './is';
2
3
  export * from './poll';
3
4
  export * from './map';
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./callback"), exports);
4
5
  tslib_1.__exportStar(require("./is"), exports);
5
6
  tslib_1.__exportStar(require("./poll"), exports);
6
7
  tslib_1.__exportStar(require("./map"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/promise/index.ts"],"names":[],"mappings":";;;AAAA,+CAAqB;AACrB,iDAAuB;AACvB,gDAAsB;AACtB,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,iDAAuB;AACvB,gDAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/promise/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,+CAAqB;AACrB,iDAAuB;AACvB,gDAAsB;AACtB,oDAA0B;AAC1B,yDAA+B;AAC/B,wDAA8B;AAC9B,iDAAuB;AACvB,gDAAsB"}
@@ -0,0 +1,34 @@
1
+ export interface FirstAndLastCharacterOccurrence {
2
+ readonly first: number | -1;
3
+ readonly last: number | -1;
4
+ /**
5
+ * Total number of occurrences.
6
+ */
7
+ readonly occurences: number;
8
+ }
9
+ /**
10
+ * Find the first and last occurence of the input character in the input string.
11
+ *
12
+ * @param input string to find the character occurrences
13
+ * @param find character to find
14
+ * @returns
15
+ */
16
+ export declare function firstAndLastCharacterOccurrence(input: string, find: string): FirstAndLastCharacterOccurrence;
17
+ /**
18
+ * Replaces the character at the given index with the replacement string.
19
+ *
20
+ * @param input
21
+ * @param index
22
+ * @param replacement
23
+ * @returns
24
+ */
25
+ export declare function replaceCharacterAtIndexWith(input: string, index: number, replacement: string): string;
26
+ /**
27
+ * Splits the input string at the given character index.
28
+ *
29
+ * @param input
30
+ * @param index
31
+ * @param replacement
32
+ * @returns
33
+ */
34
+ export declare function splitStringAtIndex(input: string, index: number, inclusive?: boolean): [string, string];
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.splitStringAtIndex = exports.replaceCharacterAtIndexWith = exports.firstAndLastCharacterOccurrence = void 0;
4
+ /**
5
+ * Find the first and last occurence of the input character in the input string.
6
+ *
7
+ * @param input string to find the character occurrences
8
+ * @param find character to find
9
+ * @returns
10
+ */
11
+ function firstAndLastCharacterOccurrence(input, find) {
12
+ let first = -1;
13
+ let last = -1;
14
+ let occurences = 0;
15
+ if (find.length !== 1) {
16
+ throw new Error('firstAndLastCharacterOccurrence() expects a single character as find input.');
17
+ }
18
+ for (let i = 0; i < input.length; i += 1) {
19
+ if (input[i] === find) {
20
+ if (first === -1) {
21
+ first = i;
22
+ }
23
+ else {
24
+ last = i;
25
+ }
26
+ occurences += 1;
27
+ }
28
+ }
29
+ if (first !== -1 && last === -1) {
30
+ last = first;
31
+ }
32
+ return {
33
+ first,
34
+ last,
35
+ occurences
36
+ };
37
+ }
38
+ exports.firstAndLastCharacterOccurrence = firstAndLastCharacterOccurrence;
39
+ /**
40
+ * Replaces the character at the given index with the replacement string.
41
+ *
42
+ * @param input
43
+ * @param index
44
+ * @param replacement
45
+ * @returns
46
+ */
47
+ function replaceCharacterAtIndexWith(input, index, replacement) {
48
+ const [head, tail] = splitStringAtIndex(input, index, false);
49
+ return head + replacement + tail;
50
+ }
51
+ exports.replaceCharacterAtIndexWith = replaceCharacterAtIndexWith;
52
+ /**
53
+ * Splits the input string at the given character index.
54
+ *
55
+ * @param input
56
+ * @param index
57
+ * @param replacement
58
+ * @returns
59
+ */
60
+ function splitStringAtIndex(input, index, inclusive = false) {
61
+ const head = input.substring(0, index);
62
+ const tail = input.substring(index + (inclusive ? 0 : 1));
63
+ return [head, tail];
64
+ }
65
+ exports.splitStringAtIndex = splitStringAtIndex;
66
+ //# sourceMappingURL=char.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"char.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/char.ts"],"names":[],"mappings":";;;AASA;;;;;;GAMG;AACH,SAAgB,+BAA+B,CAAC,KAAa,EAAE,IAAY;IACzE,IAAI,KAAK,GAAW,CAAC,CAAC,CAAC;IACvB,IAAI,IAAI,GAAW,CAAC,CAAC,CAAC;IACtB,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,MAAM,IAAI,KAAK,CAAC,6EAA6E,CAAC,CAAC;KAChG;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACxC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;YACrB,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;gBAChB,KAAK,GAAG,CAAC,CAAC;aACX;iBAAM;gBACL,IAAI,GAAG,CAAC,CAAC;aACV;YAED,UAAU,IAAI,CAAC,CAAC;SACjB;KACF;IAED,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,EAAE;QAC/B,IAAI,GAAG,KAAK,CAAC;KACd;IAED,OAAO;QACL,KAAK;QACL,IAAI;QACJ,UAAU;KACX,CAAC;AACJ,CAAC;AA9BD,0EA8BC;AAED;;;;;;;GAOG;AACH,SAAgB,2BAA2B,CAAC,KAAa,EAAE,KAAa,EAAE,WAAmB;IAC3F,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC7D,OAAO,IAAI,GAAG,WAAW,GAAG,IAAI,CAAC;AACnC,CAAC;AAHD,kEAGC;AAED;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAAC,KAAa,EAAE,KAAa,EAAE,SAAS,GAAG,KAAK;IAChF,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACvC,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACtB,CAAC;AAJD,gDAIC"}
@@ -0,0 +1,4 @@
1
+ export * from './char';
2
+ export * from './string';
3
+ export * from './replace';
4
+ export * from './transform';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./char"), exports);
5
+ tslib_1.__exportStar(require("./string"), exports);
6
+ tslib_1.__exportStar(require("./replace"), exports);
7
+ tslib_1.__exportStar(require("./transform"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB;AACvB,mDAAyB;AACzB,oDAA0B;AAC1B,sDAA4B"}
@@ -0,0 +1,30 @@
1
+ import { ArrayOrValue } from '@dereekb/util';
2
+ import { MapSameFunction } from '../value/map';
3
+ export declare type ReplaceStringsFunction = MapSameFunction<string>;
4
+ export interface ReplaceStringsConfig {
5
+ /**
6
+ * Strings to target/replace.
7
+ */
8
+ replace: ArrayOrValue<string>;
9
+ /**
10
+ * Value to replace all recurrences with.
11
+ */
12
+ replaceWith: string;
13
+ }
14
+ export declare function replaceStringsFunction(config: ReplaceStringsConfig): (input: string) => string;
15
+ export declare const REGEX_SPECIAL_CHARACTERS: string[];
16
+ export declare const REGEX_SPECIAL_CHARACTERS_SET: Set<string>;
17
+ /**
18
+ * Creates an escaped regex string joined with or values that finds all of the input values.
19
+ *
20
+ * @param find
21
+ */
22
+ export declare function findStringsRegexString(find: ArrayOrValue<string>): string;
23
+ /**
24
+ * Escapes the input string to be usable in a Regex value.
25
+ *
26
+ * For instance, 'hello.world' will be escaped to be 'hello\.world'
27
+ *
28
+ * @param input
29
+ */
30
+ export declare function escapeStringForRegex(input: string): string;
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.escapeStringForRegex = exports.findStringsRegexString = exports.REGEX_SPECIAL_CHARACTERS_SET = exports.REGEX_SPECIAL_CHARACTERS = exports.replaceStringsFunction = void 0;
4
+ const util_1 = require("@dereekb/util");
5
+ const char_1 = require("./char");
6
+ function replaceStringsFunction(config) {
7
+ const { replace: replaceInput, replaceWith } = config;
8
+ const replaceRegexString = findStringsRegexString(replaceInput);
9
+ const replaceRegex = new RegExp(replaceRegexString, 'g');
10
+ return (input) => input.replace(replaceRegex, replaceWith);
11
+ }
12
+ exports.replaceStringsFunction = replaceStringsFunction;
13
+ exports.REGEX_SPECIAL_CHARACTERS = ['\\', '^', '$', '.', '|', '?', '*', '+', '(', ')', '[', ']', '{', '}'];
14
+ exports.REGEX_SPECIAL_CHARACTERS_SET = new Set(exports.REGEX_SPECIAL_CHARACTERS);
15
+ /**
16
+ * Creates an escaped regex string joined with or values that finds all of the input values.
17
+ *
18
+ * @param find
19
+ */
20
+ function findStringsRegexString(find) {
21
+ const input = (0, util_1.asArray)(find);
22
+ const escapedInput = input.map(escapeStringForRegex);
23
+ return escapedInput.join('|');
24
+ }
25
+ exports.findStringsRegexString = findStringsRegexString;
26
+ /**
27
+ * Escapes the input string to be usable in a Regex value.
28
+ *
29
+ * For instance, 'hello.world' will be escaped to be 'hello\.world'
30
+ *
31
+ * @param input
32
+ */
33
+ function escapeStringForRegex(input) {
34
+ /**
35
+ * index of all occurences in the input to replace/merge together.
36
+ */
37
+ const occurrences = [];
38
+ for (let i = 0; i < input.length; i += 1) {
39
+ const char = input[i];
40
+ if (exports.REGEX_SPECIAL_CHARACTERS_SET.has(char)) {
41
+ occurrences.push(i);
42
+ }
43
+ }
44
+ let result;
45
+ function escapeCharacter(char) {
46
+ return `\\${char}`;
47
+ }
48
+ switch (occurrences.length) {
49
+ case 0:
50
+ result = input;
51
+ break;
52
+ case 1:
53
+ const charToReplace = input[occurrences[0]];
54
+ result = (0, char_1.replaceCharacterAtIndexWith)(input, occurrences[0], escapeCharacter(charToReplace)); //Add an escape to the character
55
+ break;
56
+ default:
57
+ const parts = [];
58
+ const endAt = occurrences.length;
59
+ let start = 0;
60
+ let occurrence = 0;
61
+ for (let i = 0; i < endAt; i += 1) {
62
+ occurrence = occurrences[i];
63
+ const char = input[occurrence];
64
+ const sub = input.substring(start, occurrence);
65
+ const part = sub + escapeCharacter(char);
66
+ parts.push(part);
67
+ start = occurrence + 1;
68
+ }
69
+ // add in the last substring
70
+ parts.push(input.substring(start));
71
+ // join all parts together
72
+ result = parts.join('');
73
+ break;
74
+ }
75
+ return result;
76
+ }
77
+ exports.escapeStringForRegex = escapeStringForRegex;
78
+ //# sourceMappingURL=replace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/replace.ts"],"names":[],"mappings":";;;AAAA,wCAAsD;AAEtD,iCAAqD;AAerD,SAAgB,sBAAsB,CAAC,MAA4B;IACjE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;IACtD,MA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} from './value/map';
2
- import { Maybe } from './value/maybe.type';
1
+ import { MapFunction } from '../value/map';
2
+ import { Maybe } from '../value/maybe.type';
3
3
  export declare type MapStringFunction<T> = MapFunction<string, T>;
4
4
  /**
5
5
  * Represents a string that is made up of comma-separated values.
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/string.ts"],"names":[],"mappings":";;;AAkBA,SAAgB,qBAAqB,CAAC,KAAoB;IACxD,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,iBAAiB,EAAE,CAAC;AACpC,CAAC;AAFD,sDAEC;AAID,SAAgB,yBAAyB,CAAc,KAA8B,EAAE,QAA8B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAiB;IAC3I,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAChC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAC5C,CAAC;AAHD,8DAGC;AAED,SAAgB,8BAA8B,CAAC,KAAkC;IAC/E,OAAO,IAAI,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACxE,CAAC;AAFD,wEAEC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAC,KAAqB,EAAE,MAAM,GAAG,GAAG;IACvE,IAAI,KAAK,IAAI,IAAI,EAAE;QACjB,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,CAAC;KACrD;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AAND,sDAMC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,KAAa;IACjD,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAFD,sDAEC"}
@@ -0,0 +1,24 @@
1
+ import { MapFunction } from '../value/map';
2
+ export declare function stringTrimFunction(input: string): string;
3
+ export declare function stringToUppercaseFunction(input: string): string;
4
+ export declare function stringToLowercaseFunction(input: string): string;
5
+ export declare type TransformStringFunctionConfig<S extends string = string> = {
6
+ /**
7
+ * Whether or not to trim the value.
8
+ */
9
+ trim?: boolean;
10
+ /**
11
+ * Whether or not to store all values as lowercase. Ignored if transform is provided.
12
+ */
13
+ toLowercase?: boolean;
14
+ /**
15
+ * Whether or not to store all values as uppercase. Ignored if transform is provided.
16
+ */
17
+ toUppercase?: boolean;
18
+ /**
19
+ * Optional transform function for text.
20
+ */
21
+ transform?: TransformStringFunction<S>;
22
+ };
23
+ export declare type TransformStringFunction<S extends string = string> = MapFunction<S, S>;
24
+ export declare function transformStringFunction<S extends string = string>(config: TransformStringFunctionConfig): TransformStringFunction<S>;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transformStringFunction = exports.stringToLowercaseFunction = exports.stringToUppercaseFunction = exports.stringTrimFunction = void 0;
4
+ const map_1 = require("../value/map");
5
+ function stringTrimFunction(input) {
6
+ return input.trim();
7
+ }
8
+ exports.stringTrimFunction = stringTrimFunction;
9
+ function stringToUppercaseFunction(input) {
10
+ return input.toUpperCase();
11
+ }
12
+ exports.stringToUppercaseFunction = stringToUppercaseFunction;
13
+ function stringToLowercaseFunction(input) {
14
+ return input.toLowerCase();
15
+ }
16
+ exports.stringToLowercaseFunction = stringToLowercaseFunction;
17
+ function transformStringFunction(config) {
18
+ let baseTransform;
19
+ if (config.transform) {
20
+ baseTransform = config.transform;
21
+ }
22
+ else if (config.toUppercase) {
23
+ baseTransform = stringToUppercaseFunction;
24
+ }
25
+ else if (config.toLowercase) {
26
+ baseTransform = stringToLowercaseFunction;
27
+ }
28
+ let transform = baseTransform;
29
+ if (config.trim) {
30
+ if (baseTransform != null) {
31
+ transform = (x) => baseTransform(stringTrimFunction(x));
32
+ }
33
+ else {
34
+ transform = stringTrimFunction;
35
+ }
36
+ }
37
+ if (transform == null) {
38
+ transform = map_1.MAP_IDENTITY;
39
+ }
40
+ return transform;
41
+ }
42
+ exports.transformStringFunction = transformStringFunction;
43
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/string/transform.ts"],"names":[],"mappings":";;;AAAA,sCAAyD;AAGzD,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC;AAFD,gDAEC;AAED,SAAgB,yBAAyB,CAAC,KAAa;IACrD,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;AAC7B,CAAC;AAFD,8DAEC;AAED,SAAgB,yBAAyB,CAAC,KAAa;IACrD,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;AAC7B,CAAC;AAFD,8DAEC;AAuBD,SAAgB,uBAAuB,CAA4B,MAAqC;IACtG,IAAI,aAA6C,CAAC;IAElD,IAAI,MAAM,CAAC,SAAS,EAAE;QACpB,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC;KAClC;SAAM,IAAI,MAAM,CAAC,WAAW,EAAE;QAC7B,aAAa,GAAG,yBAAyB,CAAC;KAC3C;SAAM,IAAI,MAAM,CAAC,WAAW,EAAE;QAC7B,aAAa,GAAG,yBAAyB,CAAC;KAC3C;IAED,IAAI,SAAS,GAAmC,aAAa,CAAC;IAE9D,IAAI,MAAM,CAAC,IAAI,EAAE;QACf,IAAI,aAAa,IAAI,IAAI,EAAE;YACzB,SAAS,GAAG,CAAC,CAAC,EAAE,EAAE,CAAE,aAAyC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC;SACtF;aAAM;YACL,SAAS,GAAG,kBAAkB,CAAC;SAChC;KACF;IAED,IAAI,SAAS,IAAI,IAAI,EAAE;QACrB,SAAS,GAAG,kBAAuC,CAAC;KACrD;IAED,OAAO,SAAkD,CAAC;AAC5D,CAAC;AA1BD,0DA0BC"}
@@ -7,3 +7,4 @@ export * from './maybe';
7
7
  export * from './modifier';
8
8
  export * from './url';
9
9
  export * from './use';
10
+ export * from './point';
@@ -10,4 +10,5 @@ tslib_1.__exportStar(require("./maybe"), exports);
10
10
  tslib_1.__exportStar(require("./modifier"), exports);
11
11
  tslib_1.__exportStar(require("./url"), exports);
12
12
  tslib_1.__exportStar(require("./use"), exports);
13
+ tslib_1.__exportStar(require("./point"), exports);
13
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,qDAA2B;AAC3B,kDAAwB;AACxB,gDAAsB;AACtB,uDAA6B;AAC7B,kDAAwB;AACxB,qDAA2B;AAC3B,gDAAsB;AACtB,gDAAsB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/util/src/lib/value/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB;AACxB,qDAA2B;AAC3B,kDAAwB;AACxB,gDAAsB;AACtB,uDAA6B;AAC7B,kDAAwB;AACxB,qDAA2B;AAC3B,gDAAsB;AACtB,gDAAsB;AACtB,kDAAwB"}