@augment-vir/common 28.2.3 → 29.0.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.
- package/dist/cjs/augments/array/array.js +9 -10
- package/dist/cjs/augments/array/remove-duplicates.js +1 -2
- package/dist/cjs/augments/async.js +3 -4
- package/dist/cjs/augments/boolean.js +3 -4
- package/dist/cjs/augments/common-number.js +10 -10
- package/dist/cjs/augments/common-string.js +16 -16
- package/dist/cjs/augments/debounce.js +2 -2
- package/dist/cjs/augments/environment.js +1 -2
- package/dist/cjs/augments/error.js +5 -6
- package/dist/cjs/augments/esm-path.js +1 -2
- package/dist/cjs/augments/json.js +2 -3
- package/dist/cjs/augments/object/enum.js +5 -6
- package/dist/cjs/augments/object/filter-object.js +3 -4
- package/dist/cjs/augments/object/get-or-set.js +2 -3
- package/dist/cjs/augments/object/has-key.js +1 -2
- package/dist/cjs/augments/object/jsonify.js +1 -2
- package/dist/cjs/augments/object/map-object.js +2 -3
- package/dist/cjs/augments/object/merge-deep.js +1 -2
- package/dist/cjs/augments/object/merge-property-arrays.js +1 -2
- package/dist/cjs/augments/object/object-entries.js +6 -7
- package/dist/cjs/augments/object/object.js +2 -3
- package/dist/cjs/augments/object/selection-set.js +2 -0
- package/dist/cjs/augments/object/typed-has-property.js +2 -3
- package/dist/cjs/augments/promise/deferred-promise.js +1 -2
- package/dist/cjs/augments/promise/promise.js +5 -5
- package/dist/cjs/augments/promise/wait.js +4 -4
- package/dist/cjs/augments/random.js +4 -5
- package/dist/cjs/augments/regexp.js +3 -4
- package/dist/cjs/augments/string/prefixes.js +2 -3
- package/dist/cjs/augments/string/suffixes.js +7 -7
- package/dist/cjs/augments/string/uuid.js +1 -2
- package/dist/cjs/augments/time.js +2 -2
- package/dist/cjs/augments/truncate-number.js +1 -2
- package/dist/cjs/augments/tuple.js +2 -3
- package/dist/cjs/augments/type.js +4 -5
- package/dist/cjs/augments/union.js +2 -0
- package/dist/cjs/augments/wrap-in-try.js +1 -2
- package/dist/cjs/index.js +3 -2
- package/dist/esm/augments/object/selection-set.js +1 -0
- package/dist/esm/augments/union.js +1 -0
- package/dist/esm/index.js +3 -2
- package/dist/types/augments/object/key-count.d.ts +13 -0
- package/dist/types/augments/object/map-object.d.ts +1 -1
- package/dist/types/augments/object/pick-deep.d.ts +0 -6
- package/dist/types/augments/object/selection-set.d.ts +25 -0
- package/dist/types/index.d.ts +3 -2
- package/package.json +2 -2
- package/dist/cjs/augments/object/nested-keys.js +0 -61
- package/dist/esm/augments/object/nested-keys.js +0 -56
- package/dist/types/augments/object/nested-keys.d.ts +0 -18
- /package/dist/cjs/augments/object/{old-union-to-intersection.js → key-count.js} +0 -0
- /package/dist/esm/augments/object/{old-union-to-intersection.js → key-count.js} +0 -0
- /package/dist/types/augments/{object/old-union-to-intersection.d.ts → union.d.ts} +0 -0
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.filterOutIndexes = filterOutIndexes;
|
|
4
|
+
exports.flatten2dArray = flatten2dArray;
|
|
5
|
+
exports.trimArrayStrings = trimArrayStrings;
|
|
6
|
+
exports.typedArrayIncludes = typedArrayIncludes;
|
|
7
|
+
exports.typedMap = typedMap;
|
|
8
|
+
exports.repeatArray = repeatArray;
|
|
9
|
+
exports.groupArrayBy = groupArrayBy;
|
|
10
|
+
exports.arrayToObject = arrayToObject;
|
|
11
|
+
exports.filterMap = filterMap;
|
|
4
12
|
const get_or_set_1 = require("../object/get-or-set");
|
|
5
13
|
const object_entries_1 = require("../object/object-entries");
|
|
6
14
|
function filterOutIndexes(array, indexes) {
|
|
7
15
|
return array.filter((_, index) => !indexes.includes(index));
|
|
8
16
|
}
|
|
9
|
-
exports.filterOutIndexes = filterOutIndexes;
|
|
10
17
|
function flatten2dArray(array2d) {
|
|
11
18
|
const flattened = array2d.reduce((accum, row) => accum.concat(row), []);
|
|
12
19
|
return flattened;
|
|
13
20
|
}
|
|
14
|
-
exports.flatten2dArray = flatten2dArray;
|
|
15
21
|
function trimArrayStrings(input) {
|
|
16
22
|
return input.map((line) => line.trim()).filter((line) => line !== '');
|
|
17
23
|
}
|
|
18
|
-
exports.trimArrayStrings = trimArrayStrings;
|
|
19
24
|
function typedArrayIncludes(array, input) {
|
|
20
25
|
return array.includes(input);
|
|
21
26
|
}
|
|
22
|
-
exports.typedArrayIncludes = typedArrayIncludes;
|
|
23
27
|
/** Preserves tuple types. */
|
|
24
28
|
function typedMap(arrayToMap, mapCallback) {
|
|
25
29
|
return arrayToMap.map(mapCallback);
|
|
26
30
|
}
|
|
27
|
-
exports.typedMap = typedMap;
|
|
28
31
|
function repeatArray(repeatCount, array) {
|
|
29
32
|
return Array.from({ length: repeatCount }, () => [...array]).flat();
|
|
30
33
|
}
|
|
31
|
-
exports.repeatArray = repeatArray;
|
|
32
34
|
/**
|
|
33
35
|
* Polyfill for `Object.groupBy`:
|
|
34
36
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy
|
|
@@ -41,7 +43,6 @@ function groupArrayBy(inputArray, callback) {
|
|
|
41
43
|
return accum;
|
|
42
44
|
}, {});
|
|
43
45
|
}
|
|
44
|
-
exports.groupArrayBy = groupArrayBy;
|
|
45
46
|
/**
|
|
46
47
|
* Like `groupArrayBy` but maps array entries to a single key. Meaning, the resulting object does
|
|
47
48
|
* not have an array of elements (unless the original array itself contains arrays).
|
|
@@ -55,7 +56,6 @@ function arrayToObject(inputArray, callback) {
|
|
|
55
56
|
];
|
|
56
57
|
}));
|
|
57
58
|
}
|
|
58
|
-
exports.arrayToObject = arrayToObject;
|
|
59
59
|
function filterMap(inputArray, mapCallback, filterCallback) {
|
|
60
60
|
return inputArray.reduce((accum, entry, index, originalArray) => {
|
|
61
61
|
const mapOutput = mapCallback(entry, index, originalArray);
|
|
@@ -66,4 +66,3 @@ function filterMap(inputArray, mapCallback, filterCallback) {
|
|
|
66
66
|
return accum;
|
|
67
67
|
}, []);
|
|
68
68
|
}
|
|
69
|
-
exports.filterMap = filterMap;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeDuplicates =
|
|
3
|
+
exports.removeDuplicates = removeDuplicates;
|
|
4
4
|
function removeDuplicates(originalArray, calculateUniqueIdCallback) {
|
|
5
5
|
const grouped = new Map();
|
|
6
6
|
return originalArray.filter((entry) => {
|
|
@@ -14,4 +14,3 @@ function removeDuplicates(originalArray, calculateUniqueIdCallback) {
|
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
exports.removeDuplicates = removeDuplicates;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.awaitedForEach = awaitedForEach;
|
|
4
|
+
exports.awaitedBlockingMap = awaitedBlockingMap;
|
|
5
|
+
exports.awaitedFilter = awaitedFilter;
|
|
4
6
|
/**
|
|
5
7
|
* Acts like calling Array.prototype.forEach in that all elements are executed upon in order, and
|
|
6
8
|
* each execution is blocking. Meaning, the callback won't be called on element 2 until the callback
|
|
@@ -9,7 +11,6 @@ exports.awaitedFilter = exports.awaitedBlockingMap = exports.awaitedForEach = vo
|
|
|
9
11
|
async function awaitedForEach(input, callback) {
|
|
10
12
|
await awaitedBlockingMap(input, callback);
|
|
11
13
|
}
|
|
12
|
-
exports.awaitedForEach = awaitedForEach;
|
|
13
14
|
async function awaitedBlockingMap(input, callback) {
|
|
14
15
|
const mappedValues = await input.reduce(async (accumPromise, currentElement, index, wholeArray) => {
|
|
15
16
|
const accum = await accumPromise;
|
|
@@ -19,11 +20,9 @@ async function awaitedBlockingMap(input, callback) {
|
|
|
19
20
|
}, Promise.resolve([]));
|
|
20
21
|
return mappedValues;
|
|
21
22
|
}
|
|
22
|
-
exports.awaitedBlockingMap = awaitedBlockingMap;
|
|
23
23
|
async function awaitedFilter(arrayInput, filterCallback, options) {
|
|
24
24
|
const callbackResults = options?.blocking
|
|
25
25
|
? await awaitedBlockingMap(arrayInput, filterCallback)
|
|
26
26
|
: await Promise.all(arrayInput.map(filterCallback));
|
|
27
27
|
return arrayInput.filter((originalValue, index) => !!callbackResults[index]);
|
|
28
28
|
}
|
|
29
|
-
exports.awaitedFilter = awaitedFilter;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isTruthy = isTruthy;
|
|
4
|
+
exports.isFalsy = isFalsy;
|
|
5
|
+
exports.ifTruthy = ifTruthy;
|
|
4
6
|
function isTruthy(input) {
|
|
5
7
|
return !!input;
|
|
6
8
|
}
|
|
7
|
-
exports.isTruthy = isTruthy;
|
|
8
9
|
function isFalsy(input) {
|
|
9
10
|
return !input;
|
|
10
11
|
}
|
|
11
|
-
exports.isFalsy = isFalsy;
|
|
12
12
|
function ifTruthy(checkThis, ifTruthyCallback, ifFalsyCallback) {
|
|
13
13
|
if (isTruthy(checkThis)) {
|
|
14
14
|
return ifTruthyCallback(checkThis);
|
|
@@ -17,4 +17,3 @@ function ifTruthy(checkThis, ifTruthyCallback, ifFalsyCallback) {
|
|
|
17
17
|
return ifFalsyCallback(checkThis);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
exports.ifTruthy = ifTruthy;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.convertIntoNumber = exports.NaNString = void 0;
|
|
4
|
+
exports.addCommasToNumber = addCommasToNumber;
|
|
5
|
+
exports.doesRequireScientificNotation = doesRequireScientificNotation;
|
|
6
|
+
exports.ensureMinAndMax = ensureMinAndMax;
|
|
7
|
+
exports.toNumber = toNumber;
|
|
8
|
+
exports.toEnsuredNumber = toEnsuredNumber;
|
|
9
|
+
exports.toMaybeNumber = toMaybeNumber;
|
|
10
|
+
exports.wrapNumber = wrapNumber;
|
|
11
|
+
exports.round = round;
|
|
12
|
+
exports.clamp = clamp;
|
|
4
13
|
const common_string_1 = require("./common-string");
|
|
5
14
|
const regexp_1 = require("./regexp");
|
|
6
15
|
exports.NaNString = String(NaN);
|
|
@@ -24,11 +33,9 @@ function addCommasToNumber(input) {
|
|
|
24
33
|
decimalString,
|
|
25
34
|
].join('');
|
|
26
35
|
}
|
|
27
|
-
exports.addCommasToNumber = addCommasToNumber;
|
|
28
36
|
function doesRequireScientificNotation(input) {
|
|
29
37
|
return String(input).includes('e');
|
|
30
38
|
}
|
|
31
|
-
exports.doesRequireScientificNotation = doesRequireScientificNotation;
|
|
32
39
|
/**
|
|
33
40
|
* Given a min and max, ensures that they are in correct order. Meaning, min is less than max. If
|
|
34
41
|
* that is not the case, the returned value is the given min and max values swapped.
|
|
@@ -41,7 +48,6 @@ function ensureMinAndMax({ min, max }) {
|
|
|
41
48
|
return { min, max };
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
|
-
exports.ensureMinAndMax = ensureMinAndMax;
|
|
45
51
|
/**
|
|
46
52
|
* Tries to convert the input into a number. Handles strings with commas. Note: this might return
|
|
47
53
|
* `NaN`.
|
|
@@ -57,7 +63,6 @@ function toNumber(input) {
|
|
|
57
63
|
return Number(input);
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
|
-
exports.toNumber = toNumber;
|
|
61
66
|
/** @deprecated Use {@link toNumber} instead. */
|
|
62
67
|
exports.convertIntoNumber = toNumber;
|
|
63
68
|
/** Tries to convert the input into a number and throws an error if `NaN` is created. */
|
|
@@ -70,7 +75,6 @@ function toEnsuredNumber(input) {
|
|
|
70
75
|
return numeric;
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
|
-
exports.toEnsuredNumber = toEnsuredNumber;
|
|
74
78
|
/** Tries to convert the input into a number and returns `undefined` if `NaN` is created. */
|
|
75
79
|
function toMaybeNumber(input) {
|
|
76
80
|
const numeric = toNumber(input);
|
|
@@ -81,7 +85,6 @@ function toMaybeNumber(input) {
|
|
|
81
85
|
return numeric;
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
|
-
exports.toMaybeNumber = toMaybeNumber;
|
|
85
88
|
/**
|
|
86
89
|
* If the given value is outside the given min/max bounds, instead of clamping the number (as the
|
|
87
90
|
* `clamp` function does), this function wraps the value around to the next bound.
|
|
@@ -98,15 +101,12 @@ function wrapNumber({ max, min, value }) {
|
|
|
98
101
|
}
|
|
99
102
|
return value;
|
|
100
103
|
}
|
|
101
|
-
exports.wrapNumber = wrapNumber;
|
|
102
104
|
function round(inputs) {
|
|
103
105
|
const digitFactor = Math.pow(10, inputs.digits);
|
|
104
106
|
const multiplied = inputs.number * digitFactor;
|
|
105
107
|
return Number((Math.round(multiplied) / digitFactor).toFixed(inputs.digits));
|
|
106
108
|
}
|
|
107
|
-
exports.round = round;
|
|
108
109
|
/** Clamp's the given value to within the min and max bounds, inclusive. */
|
|
109
110
|
function clamp({ value, min, max }) {
|
|
110
111
|
return Math.min(Math.max(value, min), max);
|
|
111
112
|
}
|
|
112
|
-
exports.clamp = clamp;
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.StringCaseEnum = exports.removeColor = void 0;
|
|
4
|
+
exports.joinWithFinalConjunction = joinWithFinalConjunction;
|
|
5
|
+
exports.wrapString = wrapString;
|
|
6
|
+
exports.removeAnsiEscapeCodes = removeAnsiEscapeCodes;
|
|
7
|
+
exports.removeCommasFromNumberString = removeCommasFromNumberString;
|
|
8
|
+
exports.collapseWhiteSpace = collapseWhiteSpace;
|
|
9
|
+
exports.splitIncludeSplit = splitIncludeSplit;
|
|
10
|
+
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
11
|
+
exports.kebabCaseToCamelCase = kebabCaseToCamelCase;
|
|
12
|
+
exports.hasCase = hasCase;
|
|
13
|
+
exports.isCase = isCase;
|
|
14
|
+
exports.camelCaseToKebabCase = camelCaseToKebabCase;
|
|
15
|
+
exports.replaceStringAtIndex = replaceStringAtIndex;
|
|
16
|
+
exports.escapeStringForRegExp = escapeStringForRegExp;
|
|
17
|
+
exports.getAllIndexesOf = getAllIndexesOf;
|
|
18
|
+
exports.typedSplit = typedSplit;
|
|
4
19
|
const ansi_1 = require("./ansi");
|
|
5
20
|
const regexp_1 = require("./regexp");
|
|
6
21
|
/**
|
|
@@ -27,7 +42,6 @@ function joinWithFinalConjunction(list, conjunction = 'and') {
|
|
|
27
42
|
const fullyJoined = `${commaJoined}${commaSep}${conjunction} ${list[list.length - 1]}`;
|
|
28
43
|
return fullyJoined;
|
|
29
44
|
}
|
|
30
|
-
exports.joinWithFinalConjunction = joinWithFinalConjunction;
|
|
31
45
|
/** Wraps `value` on both sides with `wrapper`. */
|
|
32
46
|
function wrapString({ value, wrapper }) {
|
|
33
47
|
return [
|
|
@@ -35,16 +49,13 @@ function wrapString({ value, wrapper }) {
|
|
|
35
49
|
wrapper,
|
|
36
50
|
].join(value);
|
|
37
51
|
}
|
|
38
|
-
exports.wrapString = wrapString;
|
|
39
52
|
function removeAnsiEscapeCodes(input) {
|
|
40
53
|
return input.replace(ansi_1.ansiRegex, '');
|
|
41
54
|
}
|
|
42
|
-
exports.removeAnsiEscapeCodes = removeAnsiEscapeCodes;
|
|
43
55
|
exports.removeColor = removeAnsiEscapeCodes;
|
|
44
56
|
function removeCommasFromNumberString(numberString) {
|
|
45
57
|
return numberString.replace(/,/g, '');
|
|
46
58
|
}
|
|
47
|
-
exports.removeCommasFromNumberString = removeCommasFromNumberString;
|
|
48
59
|
/** Collapse all consecutive white space into just one space and trim surrounding whitespace. */
|
|
49
60
|
function collapseWhiteSpace(input, { keepNewLines } = {}) {
|
|
50
61
|
const newLineReplacement = keepNewLines
|
|
@@ -56,7 +67,6 @@ function collapseWhiteSpace(input, { keepNewLines } = {}) {
|
|
|
56
67
|
.replace(/[^\S\r\n]/g, ' ')
|
|
57
68
|
.replace(/\s{2,}/g, ' ');
|
|
58
69
|
}
|
|
59
|
-
exports.collapseWhiteSpace = collapseWhiteSpace;
|
|
60
70
|
/** Same as String.prototype.split but includes the delimiter to split by in the output array. */
|
|
61
71
|
function splitIncludeSplit(original, splitterInput, caseSensitive) {
|
|
62
72
|
const indexLengths = getAllIndexesOf({
|
|
@@ -81,7 +91,6 @@ function splitIncludeSplit(original, splitterInput, caseSensitive) {
|
|
|
81
91
|
}, []);
|
|
82
92
|
return splitterIncluded;
|
|
83
93
|
}
|
|
84
|
-
exports.splitIncludeSplit = splitIncludeSplit;
|
|
85
94
|
const defaultCasingOptions = {
|
|
86
95
|
capitalizeFirstLetter: false,
|
|
87
96
|
};
|
|
@@ -92,7 +101,6 @@ function capitalizeFirstLetter(input) {
|
|
|
92
101
|
const firstLetter = input[0];
|
|
93
102
|
return (firstLetter.toUpperCase() + input.slice(1));
|
|
94
103
|
}
|
|
95
|
-
exports.capitalizeFirstLetter = capitalizeFirstLetter;
|
|
96
104
|
function maybeCapitalize(input, casingOptions) {
|
|
97
105
|
return casingOptions.capitalizeFirstLetter ? capitalizeFirstLetter(input) : input;
|
|
98
106
|
}
|
|
@@ -115,7 +123,6 @@ function kebabCaseToCamelCase(rawKebabCase, casingOptions = defaultCasingOptions
|
|
|
115
123
|
});
|
|
116
124
|
return maybeCapitalize(camelCase, casingOptions);
|
|
117
125
|
}
|
|
118
|
-
exports.kebabCaseToCamelCase = kebabCaseToCamelCase;
|
|
119
126
|
var StringCaseEnum;
|
|
120
127
|
(function (StringCaseEnum) {
|
|
121
128
|
StringCaseEnum["Upper"] = "upper";
|
|
@@ -125,7 +132,6 @@ var StringCaseEnum;
|
|
|
125
132
|
function hasCase(input) {
|
|
126
133
|
return input.toLowerCase() !== input.toUpperCase();
|
|
127
134
|
}
|
|
128
|
-
exports.hasCase = hasCase;
|
|
129
135
|
/**
|
|
130
136
|
* Checks if the given string is exclusively of the specific case.
|
|
131
137
|
*
|
|
@@ -157,7 +163,6 @@ function isCase(input, caseType, options) {
|
|
|
157
163
|
}
|
|
158
164
|
return true;
|
|
159
165
|
}
|
|
160
|
-
exports.isCase = isCase;
|
|
161
166
|
function camelCaseToKebabCase(rawCamelCase) {
|
|
162
167
|
const kebabCase = rawCamelCase
|
|
163
168
|
.split('')
|
|
@@ -179,13 +184,11 @@ function camelCaseToKebabCase(rawCamelCase) {
|
|
|
179
184
|
.toLowerCase();
|
|
180
185
|
return kebabCase;
|
|
181
186
|
}
|
|
182
|
-
exports.camelCaseToKebabCase = camelCaseToKebabCase;
|
|
183
187
|
function replaceStringAtIndex(originalString, start, newString, length = newString.length) {
|
|
184
188
|
const before = originalString.substring(0, start);
|
|
185
189
|
const after = originalString.substring(start + length);
|
|
186
190
|
return `${before}${newString}${after}`;
|
|
187
191
|
}
|
|
188
|
-
exports.replaceStringAtIndex = replaceStringAtIndex;
|
|
189
192
|
/**
|
|
190
193
|
* Escapes characters from the given string so that it can be used within a RegExp without being
|
|
191
194
|
* parsed as RegExp syntax.
|
|
@@ -193,7 +196,6 @@ exports.replaceStringAtIndex = replaceStringAtIndex;
|
|
|
193
196
|
function escapeStringForRegExp(input) {
|
|
194
197
|
return input.replace(/[\^$\\.*+?()[\]{}|]/g, '\\$&');
|
|
195
198
|
}
|
|
196
|
-
exports.escapeStringForRegExp = escapeStringForRegExp;
|
|
197
199
|
function makeCaseInsensitiveRegExp(searchForInput, caseSensitive) {
|
|
198
200
|
const regExpFlags = `g${!caseSensitive && typeof searchForInput === 'string' ? 'i' : ''}`;
|
|
199
201
|
const searchFor = searchForInput instanceof RegExp
|
|
@@ -238,8 +240,6 @@ function getAllIndexesOf({ searchIn, searchFor, caseSensitive, includeLength, })
|
|
|
238
240
|
});
|
|
239
241
|
return (includeLength ? indexesAndLengths : indexes);
|
|
240
242
|
}
|
|
241
|
-
exports.getAllIndexesOf = getAllIndexesOf;
|
|
242
243
|
function typedSplit(input, splitString) {
|
|
243
244
|
return input.split(splitString);
|
|
244
245
|
}
|
|
245
|
-
exports.typedSplit = typedSplit;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DebounceStyle = void 0;
|
|
4
|
+
exports.createDebounce = createDebounce;
|
|
4
5
|
var DebounceStyle;
|
|
5
6
|
(function (DebounceStyle) {
|
|
6
7
|
/**
|
|
@@ -35,4 +36,3 @@ function createDebounce(debounceStyle, debounceDuration) {
|
|
|
35
36
|
nextCallTimestamp = now + debounceDuration.milliseconds;
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
|
-
exports.createDebounce = createDebounce;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.combineErrors = combineErrors;
|
|
4
|
+
exports.combineErrorMessages = combineErrorMessages;
|
|
5
|
+
exports.extractErrorMessage = extractErrorMessage;
|
|
6
|
+
exports.ensureError = ensureError;
|
|
7
|
+
exports.ensureErrorAndPrependMessage = ensureErrorAndPrependMessage;
|
|
4
8
|
const boolean_1 = require("./boolean");
|
|
5
9
|
const typed_has_property_1 = require("./object/typed-has-property");
|
|
6
10
|
function combineErrors(errors) {
|
|
@@ -13,14 +17,12 @@ function combineErrors(errors) {
|
|
|
13
17
|
}
|
|
14
18
|
return new Error(errors.map((error) => extractErrorMessage(error).trim()).join('\n'));
|
|
15
19
|
}
|
|
16
|
-
exports.combineErrors = combineErrors;
|
|
17
20
|
function combineErrorMessages(errors) {
|
|
18
21
|
if (!errors) {
|
|
19
22
|
return '';
|
|
20
23
|
}
|
|
21
24
|
return errors.map(extractErrorMessage).filter(boolean_1.isTruthy).join('\n');
|
|
22
25
|
}
|
|
23
|
-
exports.combineErrorMessages = combineErrorMessages;
|
|
24
26
|
function extractErrorMessage(maybeError) {
|
|
25
27
|
if (!maybeError) {
|
|
26
28
|
return '';
|
|
@@ -35,7 +37,6 @@ function extractErrorMessage(maybeError) {
|
|
|
35
37
|
return String(maybeError);
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
|
-
exports.extractErrorMessage = extractErrorMessage;
|
|
39
40
|
function ensureError(maybeError) {
|
|
40
41
|
if (maybeError instanceof Error) {
|
|
41
42
|
return maybeError;
|
|
@@ -44,10 +45,8 @@ function ensureError(maybeError) {
|
|
|
44
45
|
return new Error(extractErrorMessage(maybeError));
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
exports.ensureError = ensureError;
|
|
48
48
|
function ensureErrorAndPrependMessage(maybeError, prependMessage) {
|
|
49
49
|
const error = ensureError(maybeError);
|
|
50
50
|
error.message = `${prependMessage}: ${error.message}`;
|
|
51
51
|
return error;
|
|
52
52
|
}
|
|
53
|
-
exports.ensureErrorAndPrependMessage = ensureErrorAndPrependMessage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEsmPath =
|
|
3
|
+
exports.getEsmPath = getEsmPath;
|
|
4
4
|
function getEsmPath(importMeta) {
|
|
5
5
|
const filePath = new URL('', importMeta.url).pathname;
|
|
6
6
|
const dirPath = new URL('.', importMeta.url).pathname;
|
|
@@ -9,4 +9,3 @@ function getEsmPath(importMeta) {
|
|
|
9
9
|
dirPath,
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
exports.getEsmPath = getEsmPath;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseJson = parseJson;
|
|
4
|
+
exports.stringifyJson = stringifyJson;
|
|
4
5
|
const wrap_in_try_1 = require("./wrap-in-try");
|
|
5
6
|
function parseJson({ jsonString, errorHandler, }) {
|
|
6
7
|
try {
|
|
@@ -16,7 +17,6 @@ function parseJson({ jsonString, errorHandler, }) {
|
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
}
|
|
19
|
-
exports.parseJson = parseJson;
|
|
20
20
|
function stringifyJson(jsonValue, { whitespace, ...tryOptions } = {}) {
|
|
21
21
|
const result = (0, wrap_in_try_1.wrapInTry)(() => JSON.stringify(jsonValue, undefined, whitespace), tryOptions);
|
|
22
22
|
if (result instanceof Error) {
|
|
@@ -26,4 +26,3 @@ function stringifyJson(jsonValue, { whitespace, ...tryOptions } = {}) {
|
|
|
26
26
|
return result;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
exports.stringifyJson = stringifyJson;
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getEnumTypedKeys = getEnumTypedKeys;
|
|
4
|
+
exports.getEnumTypedValues = getEnumTypedValues;
|
|
5
|
+
exports.isEnumValue = isEnumValue;
|
|
6
|
+
exports.ensureEnum = ensureEnum;
|
|
7
|
+
exports.filterToEnumValues = filterToEnumValues;
|
|
4
8
|
const object_entries_1 = require("./object-entries");
|
|
5
9
|
function getEnumTypedKeys(input) {
|
|
6
10
|
// enum keys are always strings
|
|
7
11
|
return (0, object_entries_1.getObjectTypedKeys)(input).filter((key) => isNaN(Number(key)));
|
|
8
12
|
}
|
|
9
|
-
exports.getEnumTypedKeys = getEnumTypedKeys;
|
|
10
13
|
function getEnumTypedValues(input) {
|
|
11
14
|
const keys = getEnumTypedKeys(input);
|
|
12
15
|
return keys.map((key) => input[key]);
|
|
13
16
|
}
|
|
14
|
-
exports.getEnumTypedValues = getEnumTypedValues;
|
|
15
17
|
/** Check if the given value is within the given enum. */
|
|
16
18
|
function isEnumValue(input, checkEnum) {
|
|
17
19
|
return getEnumTypedValues(checkEnum).includes(input);
|
|
18
20
|
}
|
|
19
|
-
exports.isEnumValue = isEnumValue;
|
|
20
21
|
/** Interpret a primitive as an enum value with type safety. */
|
|
21
22
|
function ensureEnum(value, checkEnum) {
|
|
22
23
|
if (isEnumValue(value, checkEnum)) {
|
|
@@ -27,7 +28,6 @@ function ensureEnum(value, checkEnum) {
|
|
|
27
28
|
throw new Error(`Given value '${value}' does not match given enum. Possible enum values: ${enumValues.join(',')}`);
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
|
-
exports.ensureEnum = ensureEnum;
|
|
31
31
|
function filterToEnumValues(inputs, checkEnum, caseInsensitive = false) {
|
|
32
32
|
if (caseInsensitive) {
|
|
33
33
|
return inputs.reduce((accum, currentInput) => {
|
|
@@ -46,4 +46,3 @@ function filterToEnumValues(inputs, checkEnum, caseInsensitive = false) {
|
|
|
46
46
|
return inputs.filter((input) => isEnumValue(input, checkEnum));
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
exports.filterToEnumValues = filterToEnumValues;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.filterObject = filterObject;
|
|
4
|
+
exports.omitObjectKeys = omitObjectKeys;
|
|
5
|
+
exports.pickObjectKeys = pickObjectKeys;
|
|
4
6
|
const object_entries_1 = require("./object-entries");
|
|
5
7
|
function filterObject(inputObject, callback) {
|
|
6
8
|
const filteredKeys = (0, object_entries_1.getObjectTypedKeys)(inputObject).filter((key) => {
|
|
@@ -12,16 +14,13 @@ function filterObject(inputObject, callback) {
|
|
|
12
14
|
return accum;
|
|
13
15
|
}, {});
|
|
14
16
|
}
|
|
15
|
-
exports.filterObject = filterObject;
|
|
16
17
|
function omitObjectKeys(inputObject, omitTheseKeys) {
|
|
17
18
|
return filterObject(inputObject, (currentKey) => {
|
|
18
19
|
return !omitTheseKeys.includes(currentKey);
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
|
-
exports.omitObjectKeys = omitObjectKeys;
|
|
22
22
|
function pickObjectKeys(inputObject, pickTheseKeys) {
|
|
23
23
|
return filterObject(inputObject, (currentKey) => {
|
|
24
24
|
return pickTheseKeys.includes(currentKey);
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
exports.pickObjectKeys = pickObjectKeys;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getOrSetFromMap = getOrSetFromMap;
|
|
4
|
+
exports.getOrSet = getOrSet;
|
|
4
5
|
const run_time_assertions_1 = require("run-time-assertions");
|
|
5
6
|
function getOrSetFromMap(map, key, createNewValueCallback) {
|
|
6
7
|
const mapKey = key;
|
|
@@ -13,7 +14,6 @@ function getOrSetFromMap(map, key, createNewValueCallback) {
|
|
|
13
14
|
return newValue;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
exports.getOrSetFromMap = getOrSetFromMap;
|
|
17
17
|
function getOrSet(originalObject, key, createCallback) {
|
|
18
18
|
if (key in originalObject) {
|
|
19
19
|
return originalObject[key];
|
|
@@ -38,4 +38,3 @@ function getOrSet(originalObject, key, createCallback) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
exports.getOrSet = getOrSet;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.mapObjectValuesSync = mapObjectValuesSync;
|
|
4
|
+
exports.mapObjectValues = mapObjectValues;
|
|
4
5
|
const object_entries_1 = require("./object-entries");
|
|
5
6
|
/**
|
|
6
7
|
* Map an object's keys to new values synchronously. This is different from plain mapObjectValues in
|
|
@@ -24,7 +25,6 @@ function mapObjectValuesSync(inputObject) {
|
|
|
24
25
|
}
|
|
25
26
|
return innerMap;
|
|
26
27
|
}
|
|
27
|
-
exports.mapObjectValuesSync = mapObjectValuesSync;
|
|
28
28
|
/**
|
|
29
29
|
* Creates a new object with the same properties as the input object, but with values set to the
|
|
30
30
|
* result of mapCallback for each property.
|
|
@@ -59,4 +59,3 @@ function mapObjectValues(inputObject, mapCallback) {
|
|
|
59
59
|
return mappedObject;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
exports.mapObjectValues = mapObjectValues;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeDeep =
|
|
3
|
+
exports.mergeDeep = mergeDeep;
|
|
4
4
|
const run_time_assertions_1 = require("run-time-assertions");
|
|
5
5
|
const tuple_1 = require("../tuple");
|
|
6
6
|
/**
|
|
@@ -50,4 +50,3 @@ function mergeDeep(...inputs) {
|
|
|
50
50
|
}
|
|
51
51
|
return result;
|
|
52
52
|
}
|
|
53
|
-
exports.mergeDeep = mergeDeep;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergePropertyArrays =
|
|
3
|
+
exports.mergePropertyArrays = mergePropertyArrays;
|
|
4
4
|
const get_or_set_1 = require("./get-or-set");
|
|
5
5
|
function mergePropertyArrays(...inputs) {
|
|
6
6
|
const combined = {};
|
|
@@ -12,4 +12,3 @@ function mergePropertyArrays(...inputs) {
|
|
|
12
12
|
});
|
|
13
13
|
return combined;
|
|
14
14
|
}
|
|
15
|
-
exports.mergePropertyArrays = mergePropertyArrays;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isKeyof = isKeyof;
|
|
4
|
+
exports.getObjectTypedKeys = getObjectTypedKeys;
|
|
5
|
+
exports.getObjectTypedValues = getObjectTypedValues;
|
|
6
|
+
exports.getObjectTypedEntries = getObjectTypedEntries;
|
|
7
|
+
exports.getEntriesSortedByKey = getEntriesSortedByKey;
|
|
8
|
+
exports.typedObjectFromEntries = typedObjectFromEntries;
|
|
4
9
|
const typed_has_property_1 = require("./typed-has-property");
|
|
5
10
|
/** @deprecated This is the same as hasKey */
|
|
6
11
|
function isKeyof(key, object) {
|
|
7
12
|
return (0, typed_has_property_1.typedHasProperty)(object, key);
|
|
8
13
|
}
|
|
9
|
-
exports.isKeyof = isKeyof;
|
|
10
14
|
function getObjectTypedKeys(input) {
|
|
11
15
|
let reflectKeys;
|
|
12
16
|
try {
|
|
@@ -19,23 +23,18 @@ function getObjectTypedKeys(input) {
|
|
|
19
23
|
...Object.getOwnPropertySymbols(input),
|
|
20
24
|
]);
|
|
21
25
|
}
|
|
22
|
-
exports.getObjectTypedKeys = getObjectTypedKeys;
|
|
23
26
|
function getObjectTypedValues(input) {
|
|
24
27
|
return getObjectTypedKeys(input).map((key) => input[key]);
|
|
25
28
|
}
|
|
26
|
-
exports.getObjectTypedValues = getObjectTypedValues;
|
|
27
29
|
function getObjectTypedEntries(input) {
|
|
28
30
|
return getObjectTypedKeys(input).map((key) => [
|
|
29
31
|
key,
|
|
30
32
|
input[key],
|
|
31
33
|
]);
|
|
32
34
|
}
|
|
33
|
-
exports.getObjectTypedEntries = getObjectTypedEntries;
|
|
34
35
|
function getEntriesSortedByKey(input) {
|
|
35
36
|
return Object.entries(input).sort((tupleA, tupleB) => tupleA[0].localeCompare(tupleB[0]));
|
|
36
37
|
}
|
|
37
|
-
exports.getEntriesSortedByKey = getEntriesSortedByKey;
|
|
38
38
|
function typedObjectFromEntries(entries) {
|
|
39
39
|
return Object.fromEntries(entries);
|
|
40
40
|
}
|
|
41
|
-
exports.typedObjectFromEntries = typedObjectFromEntries;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isObject = isObject;
|
|
4
|
+
exports.copyThroughJson = copyThroughJson;
|
|
4
5
|
/** Checks if the input is non-null and an object. Includes arrays. */
|
|
5
6
|
function isObject(input) {
|
|
6
7
|
return !!input && typeof input === 'object';
|
|
7
8
|
}
|
|
8
|
-
exports.isObject = isObject;
|
|
9
9
|
/** The input here must be serializable otherwise JSON parsing errors will be thrown */
|
|
10
10
|
function copyThroughJson(input) {
|
|
11
11
|
try {
|
|
@@ -16,4 +16,3 @@ function copyThroughJson(input) {
|
|
|
16
16
|
throw error;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
exports.copyThroughJson = copyThroughJson;
|