@koine/utils 2.0.0-beta.1 → 2.0.0-beta.11
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/Defer.mjs +6 -5
- package/Emitter.d.ts +3 -1
- package/Emitter.mjs +16 -17
- package/README.md +6 -1
- package/accentSets.d.ts +3 -2
- package/accentSets.mjs +116 -31
- package/addOrReplaceAtIdx.d.ts +4 -0
- package/addOrReplaceAtIdx.mjs +13 -6
- package/areEqual.d.ts +1 -1
- package/areEqual.mjs +17 -23
- package/arrayOfAll.d.ts +1 -2
- package/arrayOfAll.mjs +2 -8
- package/arraySum.d.ts +2 -1
- package/arraySum.mjs +3 -5
- package/arrayToLookup.mjs +2 -4
- package/buildUrlQueryString.mjs +11 -14
- package/capitalize.d.ts +2 -1
- package/capitalize.mjs +5 -6
- package/changeUrlPath.mjs +2 -3
- package/chunkByChunks.d.ts +1 -1
- package/chunkByChunks.mjs +18 -21
- package/chunkBySize.mjs +3 -4
- package/clamp.mjs +1 -2
- package/clsx.d.ts +6 -2
- package/clsx.mjs +14 -15
- package/convertRange.d.ts +3 -1
- package/convertRange.mjs +5 -4
- package/cookie.d.ts +13 -1
- package/cookie.mjs +8 -3
- package/createPalette.d.ts +3 -1
- package/createPalette.mjs +17 -7
- package/debounce.mjs +9 -17
- package/debouncePromise.d.ts +22 -4
- package/debouncePromise.mjs +73 -3
- package/debounceRaf.d.ts +1 -1
- package/debounceRaf.mjs +6 -11
- package/decode.mjs +2 -3
- package/encode.mjs +2 -3
- package/ensureInt.mjs +1 -4
- package/env.mjs +0 -1
- package/errorToString.d.ts +2 -1
- package/errorToString.mjs +3 -5
- package/findDuplicatedIndexes.mjs +4 -5
- package/forin.d.ts +2 -1
- package/forin.mjs +4 -4
- package/gbToBytes.mjs +1 -2
- package/getEmptyArray.d.ts +0 -1
- package/getEmptyArray.mjs +4 -4
- package/getKeys.d.ts +2 -1
- package/getKeys.mjs +3 -3
- package/getMediaQueryWidthResolvers.d.ts +6 -0
- package/getMediaQueryWidthResolvers.mjs +49 -50
- package/getMediaQueryWidthTailwindScreens.d.ts +4 -0
- package/getMediaQueryWidthTailwindScreens.mjs +22 -15
- package/getNonce.mjs +1 -2
- package/getParamAmong.d.ts +3 -2
- package/getParamAmong.mjs +5 -6
- package/getParamAsInt.d.ts +2 -2
- package/getParamAsInt.mjs +4 -6
- package/getParamAsString.d.ts +1 -1
- package/getParamAsString.mjs +2 -3
- package/getType.d.ts +0 -3
- package/getType.mjs +2 -7
- package/getUrlHashParams.mjs +2 -4
- package/getUrlHashPathname.mjs +1 -3
- package/getUrlPathnameParts.mjs +2 -7
- package/getUrlQueryParams.d.ts +3 -4
- package/getUrlQueryParams.mjs +10 -22
- package/imgEmptyPixel.mjs +1 -2
- package/index.d.ts +5 -2
- package/index.mjs +2 -2
- package/invariant.mjs +6 -8
- package/isAnyObject.mjs +1 -2
- package/isArray.mjs +1 -2
- package/isBlob.mjs +1 -2
- package/isBoolean.mjs +1 -2
- package/isBrowser.mjs +1 -2
- package/isBrowserNow.mjs +1 -2
- package/isDate.mjs +1 -2
- package/isEmptyArray.mjs +1 -2
- package/isEmptyObject.mjs +1 -2
- package/isEmptyString.mjs +1 -2
- package/isError.mjs +1 -2
- package/isExternalUrl.mjs +4 -6
- package/isFile.mjs +1 -2
- package/isFloat.mjs +1 -2
- package/isFormData.mjs +1 -2
- package/isFullArray.mjs +1 -2
- package/isFullObject.mjs +1 -2
- package/isFullString.mjs +1 -2
- package/isFunction.mjs +1 -2
- package/isInt.mjs +1 -2
- package/isMap.mjs +1 -2
- package/isNaNValue.mjs +1 -2
- package/isNegativeNumber.mjs +1 -2
- package/isNull.mjs +1 -2
- package/isNullOrUndefined.mjs +1 -2
- package/isNumber.mjs +1 -2
- package/isObject.mjs +1 -2
- package/isObjectLike.mjs +1 -2
- package/isOneOf.mjs +1 -7
- package/isPlainObject.mjs +3 -6
- package/isPositiveNumber.mjs +1 -2
- package/isPrimitive.mjs +5 -11
- package/isPromise.mjs +1 -2
- package/isRegExp.mjs +1 -2
- package/isServer.mjs +1 -2
- package/isServerNow.mjs +1 -2
- package/isSet.mjs +1 -2
- package/isString.mjs +1 -2
- package/isSymbol.mjs +1 -2
- package/isType.mjs +3 -5
- package/isUndefined.mjs +1 -2
- package/isWeakMap.mjs +1 -2
- package/isWeakSet.mjs +1 -2
- package/kbToBytes.mjs +1 -2
- package/location.mjs +3 -1
- package/lowercase.mjs +1 -4
- package/mapListBy.mjs +2 -5
- package/matchSorter.mjs +110 -128
- package/mbToBytes.mjs +1 -2
- package/mergeObjects.d.ts +2 -2
- package/mergeObjects.mjs +13 -16
- package/mergeUrlQueryParams.d.ts +0 -1
- package/mergeUrlQueryParams.mjs +4 -9
- package/moveSortableArrayItemByKey.d.ts +1 -1
- package/moveSortableArrayItemByKey.mjs +9 -9
- package/noop.mjs +1 -2
- package/normaliseUrl.mjs +1 -3
- package/normaliseUrlPathname.mjs +1 -3
- package/objectOmit.d.ts +1 -1
- package/objectOmit.mjs +4 -6
- package/objectPick.d.ts +1 -1
- package/objectPick.mjs +5 -6
- package/package.json +7 -11
- package/parseCookie.mjs +11 -15
- package/parseURL.mjs +5 -6
- package/quaranteneProps.d.ts +1 -1
- package/quaranteneProps.mjs +7 -9
- package/randomInt.mjs +1 -2
- package/randomKey.mjs +3 -4
- package/readCookie.d.ts +5 -0
- package/readCookie.mjs +7 -8
- package/removeAccents.mjs +5 -8
- package/removeCookie.d.ts +0 -4
- package/removeCookie.mjs +6 -9
- package/removeDuplicates.mjs +0 -1
- package/removeDuplicatesByKey.mjs +5 -7
- package/removeDuplicatesComparing.mjs +3 -4
- package/removeIndexesFromArray.mjs +3 -4
- package/removeTrailingSlash.mjs +1 -3
- package/removeUrlQueryParams.d.ts +0 -1
- package/removeUrlQueryParams.mjs +5 -8
- package/render.d.ts +2 -1
- package/render.mjs +45 -99
- package/roundTo.mjs +15 -17
- package/serializeCookie.d.ts +1 -5
- package/serializeCookie.mjs +10 -20
- package/setCookie.d.ts +0 -4
- package/setCookie.mjs +13 -20
- package/shuffle.d.ts +7 -6
- package/shuffle.mjs +17 -16
- package/slugify.d.ts +2 -1
- package/slugify.mjs +15 -12
- package/split.d.ts +4 -0
- package/split.mjs +4 -1
- package/swapMap.d.ts +1 -1
- package/swapMap.mjs +4 -6
- package/throttle.d.ts +2 -1
- package/throttle.mjs +6 -12
- package/titleCase.d.ts +4 -3
- package/titleCase.mjs +5 -9
- package/toNumber.mjs +1 -2
- package/toRgba.mjs +3 -5
- package/transformToUrlPathname.mjs +2 -5
- package/truncate.d.ts +1 -1
- package/truncate.mjs +2 -9
- package/tryUntil.d.ts +4 -1
- package/tryUntil.mjs +11 -11
- package/types.mjs +2 -1
- package/typings.d.ts +1 -6
- package/uid.mjs +3 -5
- package/updateLinkParams.mjs +2 -3
- package/updateUrlQueryParams.d.ts +0 -1
- package/updateUrlQueryParams.mjs +3 -8
- package/uppercase.d.ts +1 -0
- package/uppercase.mjs +2 -4
- package/uuid.mjs +2 -5
- package/uuidNumeric.mjs +1 -2
- package/wait.mjs +1 -4
- package/without.mjs +1 -3
- package/Defer.js +0 -30
- package/Emitter.js +0 -42
- package/accentSets.js +0 -41
- package/addOrReplaceAtIdx.js +0 -23
- package/areEqual.js +0 -81
- package/arrayOfAll.js +0 -36
- package/arraySum.js +0 -13
- package/arrayToLookup.js +0 -17
- package/buildUrlQueryString.js +0 -36
- package/capitalize.js +0 -16
- package/changeUrlPath.js +0 -23
- package/chunkByChunks.js +0 -41
- package/chunkBySize.js +0 -16
- package/clamp.js +0 -14
- package/clsx.js +0 -53
- package/convertRange.js +0 -20
- package/cookie.js +0 -13
- package/createPalette.js +0 -26
- package/debounce.js +0 -33
- package/debouncePromise.js +0 -12
- package/debounceRaf.js +0 -31
- package/decode.js +0 -14
- package/encode.js +0 -14
- package/ensureInt.js +0 -13
- package/env.js +0 -3
- package/errorToString.js +0 -15
- package/findDuplicatedIndexes.js +0 -18
- package/forin.js +0 -15
- package/gbToBytes.js +0 -11
- package/getEmptyArray.js +0 -20
- package/getKeys.js +0 -12
- package/getMediaQueryWidthResolvers.js +0 -72
- package/getMediaQueryWidthTailwindScreens.js +0 -33
- package/getNonce.js +0 -13
- package/getParamAmong.js +0 -22
- package/getParamAsInt.js +0 -25
- package/getParamAsString.js +0 -19
- package/getType.js +0 -23
- package/getUrlHashParams.js +0 -20
- package/getUrlHashPathname.js +0 -17
- package/getUrlPathnameParts.js +0 -25
- package/getUrlQueryParams.js +0 -43
- package/imgEmptyPixel.js +0 -10
- package/index.js +0 -267
- package/invariant.js +0 -38
- package/isAnyObject.js +0 -15
- package/isArray.js +0 -15
- package/isBlob.js +0 -15
- package/isBoolean.js +0 -15
- package/isBrowser.js +0 -9
- package/isBrowserNow.js +0 -12
- package/isDate.js +0 -15
- package/isEmptyArray.js +0 -15
- package/isEmptyObject.js +0 -15
- package/isEmptyString.js +0 -13
- package/isError.js +0 -15
- package/isExternalUrl.js +0 -26
- package/isFile.js +0 -15
- package/isFloat.js +0 -15
- package/isFormData.js +0 -15
- package/isFullArray.js +0 -15
- package/isFullObject.js +0 -15
- package/isFullString.js +0 -15
- package/isFunction.js +0 -13
- package/isInt.js +0 -15
- package/isMap.js +0 -15
- package/isNaNValue.js +0 -15
- package/isNegativeNumber.js +0 -15
- package/isNull.js +0 -15
- package/isNullOrUndefined.js +0 -14
- package/isNumber.js +0 -17
- package/isObject.js +0 -15
- package/isObjectLike.js +0 -17
- package/isOneOf.js +0 -14
- package/isPlainObject.js +0 -18
- package/isPositiveNumber.js +0 -15
- package/isPrimitive.js +0 -25
- package/isPromise.js +0 -15
- package/isRegExp.js +0 -15
- package/isServer.js +0 -12
- package/isServerNow.js +0 -12
- package/isSet.js +0 -15
- package/isString.js +0 -15
- package/isSymbol.js +0 -15
- package/isType.js +0 -27
- package/isUndefined.js +0 -15
- package/isWeakMap.js +0 -15
- package/isWeakSet.js +0 -15
- package/kbToBytes.js +0 -11
- package/location.js +0 -2
- package/lowercase.js +0 -13
- package/mapListBy.js +0 -18
- package/matchSorter.js +0 -374
- package/mbToBytes.js +0 -11
- package/mergeObjects.js +0 -41
- package/mergeUrlQueryParams.js +0 -27
- package/moveSortableArrayItemByKey.js +0 -21
- package/noop.js +0 -11
- package/normaliseUrl.js +0 -20
- package/normaliseUrlPathname.js +0 -19
- package/objectOmit.js +0 -23
- package/objectPick.js +0 -19
- package/parseCookie.js +0 -52
- package/parseURL.js +0 -24
- package/quaranteneProps.js +0 -37
- package/randomInt.js +0 -13
- package/randomKey.js +0 -15
- package/readCookie.js +0 -38
- package/removeAccents.js +0 -19
- package/removeCookie.js +0 -19
- package/removeDuplicates.js +0 -13
- package/removeDuplicatesByKey.js +0 -24
- package/removeDuplicatesComparing.js +0 -14
- package/removeIndexesFromArray.js +0 -18
- package/removeTrailingSlash.js +0 -14
- package/removeUrlQueryParams.js +0 -26
- package/render.js +0 -169
- package/roundTo.js +0 -38
- package/serializeCookie.js +0 -108
- package/setCookie.js +0 -62
- package/shuffle.js +0 -36
- package/slugify.js +0 -27
- package/split.js +0 -8
- package/swapMap.js +0 -18
- package/throttle.js +0 -30
- package/titleCase.js +0 -15
- package/toNumber.js +0 -12
- package/toRgba.js +0 -20
- package/transformToUrlPathname.js +0 -21
- package/truncate.js +0 -17
- package/tryUntil.js +0 -31
- package/types.js +0 -2
- package/uid.js +0 -16
- package/updateLinkParams.js +0 -19
- package/updateUrlQueryParams.js +0 -23
- package/uppercase.js +0 -13
- package/uuid.js +0 -17
- package/uuidNumeric.js +0 -10
- package/wait.js +0 -13
- package/without.js +0 -56
package/matchSorter.js
DELETED
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultBaseSortFn = exports.matchSorter = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
/**
|
|
6
|
-
* @file
|
|
7
|
-
*
|
|
8
|
-
* Slightly adapted from Kent C. Dodd's [match-sorter](https://github.com/kentcdodds/match-sorter)
|
|
9
|
-
* differences are:
|
|
10
|
-
* - less exports
|
|
11
|
-
* - smaller output
|
|
12
|
-
* - no external deps
|
|
13
|
-
*
|
|
14
|
-
* TODO: turn objects into arrays for smaller output?
|
|
15
|
-
*
|
|
16
|
-
* @name match-sorter
|
|
17
|
-
* @license MIT license.
|
|
18
|
-
* @copyright (c) 2020 Kent C. Dodds
|
|
19
|
-
* @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
|
|
20
|
-
*/
|
|
21
|
-
var removeAccents_1 = tslib_1.__importDefault(require("./removeAccents"));
|
|
22
|
-
var RANKING_CASE_SENSITIVE_EQUAL = 7;
|
|
23
|
-
var RANKING_EQUAL = 6;
|
|
24
|
-
var RANKING_STARTS_WITH = 5;
|
|
25
|
-
var RANKING_WORD_STARTS_WITH = 4;
|
|
26
|
-
var RANKING_CONTAINS = 3;
|
|
27
|
-
var RANKING_ACRONYM = 2;
|
|
28
|
-
var RANKING_MATCHES = 1;
|
|
29
|
-
var RANKING_NO_MATCH = 0;
|
|
30
|
-
var defaultBaseSortFn = function (a, b) {
|
|
31
|
-
return String(a.rankedValue).localeCompare(String(b.rankedValue));
|
|
32
|
-
};
|
|
33
|
-
exports.defaultBaseSortFn = defaultBaseSortFn;
|
|
34
|
-
/**
|
|
35
|
-
* Takes an array of items and a value and returns a new array with the items that match the given value
|
|
36
|
-
* @param {Array} items - the items to sort
|
|
37
|
-
* @param {String} value - the value to use for ranking
|
|
38
|
-
* @param {Object} options - Some options to configure the sorter
|
|
39
|
-
* @return {Array} - the new sorted array
|
|
40
|
-
*/
|
|
41
|
-
function matchSorter(items, value, options) {
|
|
42
|
-
if (options === void 0) { options = {}; }
|
|
43
|
-
var keys = options.keys, _a = options.threshold, threshold = _a === void 0 ? RANKING_MATCHES : _a, _b = options.baseSort, baseSort = _b === void 0 ? defaultBaseSortFn : _b, _c = options.sorter, sorter = _c === void 0 ? function (matchedItems) {
|
|
44
|
-
return matchedItems.sort(function (a, b) { return sortRankedValues(a, b, baseSort); });
|
|
45
|
-
} : _c;
|
|
46
|
-
var matchedItems = items.reduce(reduceItemsToRanked, []);
|
|
47
|
-
return sorter(matchedItems).map(function (_a) {
|
|
48
|
-
var item = _a.item;
|
|
49
|
-
return item;
|
|
50
|
-
});
|
|
51
|
-
function reduceItemsToRanked(matches, item, index) {
|
|
52
|
-
var rankingInfo = getHighestRanking(item, keys, value, options);
|
|
53
|
-
var rank = rankingInfo.rank, _a = rankingInfo.keyThreshold, keyThreshold = _a === void 0 ? threshold : _a;
|
|
54
|
-
if (rank >= keyThreshold) {
|
|
55
|
-
matches.push(tslib_1.__assign(tslib_1.__assign({}, rankingInfo), { item: item, index: index }));
|
|
56
|
-
}
|
|
57
|
-
return matches;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.matchSorter = matchSorter;
|
|
61
|
-
/**
|
|
62
|
-
* Gets the highest ranking for value for the given item based on its values for the given keys
|
|
63
|
-
* @param {*} item - the item to rank
|
|
64
|
-
* @param {Array} keys - the keys to get values from the item for the ranking
|
|
65
|
-
* @param {String} value - the value to rank against
|
|
66
|
-
* @param {Object} options - options to control the ranking
|
|
67
|
-
* @return {{rank: Number, keyIndex: Number, keyThreshold: Number}} - the highest ranking
|
|
68
|
-
*/
|
|
69
|
-
function getHighestRanking(item, keys, value, options) {
|
|
70
|
-
if (!keys) {
|
|
71
|
-
// if keys is not specified, then we assume the item given is ready to be matched
|
|
72
|
-
var stringItem = item;
|
|
73
|
-
return {
|
|
74
|
-
// ends up being duplicate of 'item' in matches but consistent
|
|
75
|
-
rankedValue: stringItem,
|
|
76
|
-
rank: getMatchRanking(stringItem, value, options),
|
|
77
|
-
keyIndex: -1,
|
|
78
|
-
keyThreshold: options.threshold,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
var valuesToRank = getAllValuesToRank(item, keys);
|
|
82
|
-
return valuesToRank.reduce(function (_a, _b, i) {
|
|
83
|
-
var rank = _a.rank, rankedValue = _a.rankedValue, keyIndex = _a.keyIndex, keyThreshold = _a.keyThreshold;
|
|
84
|
-
var itemValue = _b.itemValue, attributes = _b.attributes;
|
|
85
|
-
var newRank = getMatchRanking(itemValue, value, options);
|
|
86
|
-
var newRankedValue = rankedValue;
|
|
87
|
-
var minRanking = attributes.minRanking, maxRanking = attributes.maxRanking, threshold = attributes.threshold;
|
|
88
|
-
if (newRank < minRanking && newRank >= RANKING_MATCHES) {
|
|
89
|
-
newRank = minRanking;
|
|
90
|
-
}
|
|
91
|
-
else if (newRank > maxRanking) {
|
|
92
|
-
newRank = maxRanking;
|
|
93
|
-
}
|
|
94
|
-
if (newRank > rank) {
|
|
95
|
-
rank = newRank;
|
|
96
|
-
keyIndex = i;
|
|
97
|
-
keyThreshold = threshold;
|
|
98
|
-
newRankedValue = itemValue;
|
|
99
|
-
}
|
|
100
|
-
return { rankedValue: newRankedValue, rank: rank, keyIndex: keyIndex, keyThreshold: keyThreshold };
|
|
101
|
-
}, {
|
|
102
|
-
rankedValue: item,
|
|
103
|
-
rank: RANKING_NO_MATCH,
|
|
104
|
-
keyIndex: -1,
|
|
105
|
-
keyThreshold: options.threshold,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Gives a rankings score based on how well the two strings match.
|
|
110
|
-
* @param {String} testString - the string to test against
|
|
111
|
-
* @param {String} stringToRank - the string to rank
|
|
112
|
-
* @param {Object} options - options for the match (like keepDiacritics for comparison)
|
|
113
|
-
* @returns {Number} the ranking for how well stringToRank matches testString
|
|
114
|
-
*/
|
|
115
|
-
function getMatchRanking(testString, stringToRank, options) {
|
|
116
|
-
testString = prepareValueForComparison(testString, options);
|
|
117
|
-
stringToRank = prepareValueForComparison(stringToRank, options);
|
|
118
|
-
// too long
|
|
119
|
-
if (stringToRank.length > testString.length) {
|
|
120
|
-
return RANKING_NO_MATCH;
|
|
121
|
-
}
|
|
122
|
-
// case sensitive equals
|
|
123
|
-
if (testString === stringToRank) {
|
|
124
|
-
return RANKING_CASE_SENSITIVE_EQUAL;
|
|
125
|
-
}
|
|
126
|
-
// Lower casing before further comparison
|
|
127
|
-
testString = testString.toLowerCase();
|
|
128
|
-
stringToRank = stringToRank.toLowerCase();
|
|
129
|
-
// case insensitive equals
|
|
130
|
-
if (testString === stringToRank) {
|
|
131
|
-
return RANKING_EQUAL;
|
|
132
|
-
}
|
|
133
|
-
// starts with
|
|
134
|
-
if (testString.startsWith(stringToRank)) {
|
|
135
|
-
return RANKING_STARTS_WITH;
|
|
136
|
-
}
|
|
137
|
-
// word starts with
|
|
138
|
-
if (testString.includes(" ".concat(stringToRank))) {
|
|
139
|
-
return RANKING_WORD_STARTS_WITH;
|
|
140
|
-
}
|
|
141
|
-
// contains
|
|
142
|
-
if (testString.includes(stringToRank)) {
|
|
143
|
-
return RANKING_CONTAINS;
|
|
144
|
-
}
|
|
145
|
-
else if (stringToRank.length === 1) {
|
|
146
|
-
// If the only character in the given stringToRank
|
|
147
|
-
// isn't even contained in the testString, then
|
|
148
|
-
// it's definitely not a match.
|
|
149
|
-
return RANKING_NO_MATCH;
|
|
150
|
-
}
|
|
151
|
-
// acronym
|
|
152
|
-
if (getAcronym(testString).includes(stringToRank)) {
|
|
153
|
-
return RANKING_ACRONYM;
|
|
154
|
-
}
|
|
155
|
-
// will return a number between RANKING_MATCHES and
|
|
156
|
-
// RANKING_MATCHES + 1 depending on how close of a match it is.
|
|
157
|
-
return getClosenessRanking(testString, stringToRank);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Generates an acronym for a string.
|
|
161
|
-
*
|
|
162
|
-
* @param {String} string the string for which to produce the acronym
|
|
163
|
-
* @returns {String} the acronym
|
|
164
|
-
*/
|
|
165
|
-
function getAcronym(string) {
|
|
166
|
-
var acronym = "";
|
|
167
|
-
var wordsInString = string.split(" ");
|
|
168
|
-
wordsInString.forEach(function (wordInString) {
|
|
169
|
-
var splitByHyphenWords = wordInString.split("-");
|
|
170
|
-
splitByHyphenWords.forEach(function (splitByHyphenWord) {
|
|
171
|
-
acronym += splitByHyphenWord.substring(0, 1);
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
return acronym;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Returns a score based on how spread apart the
|
|
178
|
-
* characters from the stringToRank are within the testString.
|
|
179
|
-
* A number close to RANKING_MATCHES represents a loose match. A number close
|
|
180
|
-
* to RANKING_MATCHES + 1 represents a tighter match.
|
|
181
|
-
* @param {String} testString - the string to test against
|
|
182
|
-
* @param {String} stringToRank - the string to rank
|
|
183
|
-
* @returns {Number} the number between RANKING_MATCHES and
|
|
184
|
-
* RANKING_MATCHES + 1 for how well stringToRank matches testString
|
|
185
|
-
*/
|
|
186
|
-
function getClosenessRanking(testString, stringToRank) {
|
|
187
|
-
var matchingInOrderCharCount = 0;
|
|
188
|
-
var charNumber = 0;
|
|
189
|
-
function findMatchingCharacter(matchChar, string, index) {
|
|
190
|
-
for (var j = index, J = string.length; j < J; j++) {
|
|
191
|
-
var stringChar = string[j];
|
|
192
|
-
if (stringChar === matchChar) {
|
|
193
|
-
matchingInOrderCharCount += 1;
|
|
194
|
-
return j + 1;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
return -1;
|
|
198
|
-
}
|
|
199
|
-
function getRanking(spread) {
|
|
200
|
-
var spreadPercentage = 1 / spread;
|
|
201
|
-
var inOrderPercentage = matchingInOrderCharCount / stringToRank.length;
|
|
202
|
-
var ranking = RANKING_MATCHES + inOrderPercentage * spreadPercentage;
|
|
203
|
-
return ranking;
|
|
204
|
-
}
|
|
205
|
-
var firstIndex = findMatchingCharacter(stringToRank[0], testString, 0);
|
|
206
|
-
if (firstIndex < 0) {
|
|
207
|
-
return RANKING_NO_MATCH;
|
|
208
|
-
}
|
|
209
|
-
charNumber = firstIndex;
|
|
210
|
-
for (var i = 1, I = stringToRank.length; i < I; i++) {
|
|
211
|
-
var matchChar = stringToRank[i];
|
|
212
|
-
charNumber = findMatchingCharacter(matchChar, testString, charNumber);
|
|
213
|
-
var found = charNumber > -1;
|
|
214
|
-
if (!found) {
|
|
215
|
-
return RANKING_NO_MATCH;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
var spread = charNumber - firstIndex;
|
|
219
|
-
return getRanking(spread);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Sorts items that have a rank, index, and keyIndex
|
|
223
|
-
* @param {Object} a - the first item to sort
|
|
224
|
-
* @param {Object} b - the second item to sort
|
|
225
|
-
* @return {Number} -1 if a should come first, 1 if b should come first, 0 if equal
|
|
226
|
-
*/
|
|
227
|
-
function sortRankedValues(a, b, baseSort) {
|
|
228
|
-
var aFirst = -1;
|
|
229
|
-
var bFirst = 1;
|
|
230
|
-
var aRank = a.rank, aKeyIndex = a.keyIndex;
|
|
231
|
-
var bRank = b.rank, bKeyIndex = b.keyIndex;
|
|
232
|
-
var same = aRank === bRank;
|
|
233
|
-
if (same) {
|
|
234
|
-
if (aKeyIndex === bKeyIndex) {
|
|
235
|
-
// use the base sort function as a tie-breaker
|
|
236
|
-
return baseSort(a, b);
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
return aKeyIndex < bKeyIndex ? aFirst : bFirst;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
return aRank > bRank ? aFirst : bFirst;
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
/**
|
|
247
|
-
* Prepares value for comparison by stringifying it, removing diacritics (if specified)
|
|
248
|
-
* @param {String} value - the value to clean
|
|
249
|
-
* @param {Object} options - {keepDiacritics: whether to remove diacritics}
|
|
250
|
-
* @return {String} the prepared value
|
|
251
|
-
*/
|
|
252
|
-
function prepareValueForComparison(value, _a) {
|
|
253
|
-
var keepDiacritics = _a.keepDiacritics;
|
|
254
|
-
// value might not actually be a string at this point (we don't get to choose)
|
|
255
|
-
// so part of preparing the value for comparison is ensure that it is a string
|
|
256
|
-
value = "".concat(value); // toString
|
|
257
|
-
if (!keepDiacritics) {
|
|
258
|
-
value = (0, removeAccents_1.default)(value);
|
|
259
|
-
}
|
|
260
|
-
return value;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Gets value for key in item at arbitrarily nested keypath
|
|
264
|
-
* @param {Object} item - the item
|
|
265
|
-
* @param {Object|Function} key - the potentially nested keypath or property callback
|
|
266
|
-
* @return {Array} - an array containing the value(s) at the nested keypath
|
|
267
|
-
*/
|
|
268
|
-
function getItemValues(item, key) {
|
|
269
|
-
if (typeof key === "object") {
|
|
270
|
-
key = key.key;
|
|
271
|
-
}
|
|
272
|
-
var value;
|
|
273
|
-
if (typeof key === "function") {
|
|
274
|
-
value = key(item);
|
|
275
|
-
}
|
|
276
|
-
else if (item == null) {
|
|
277
|
-
value = null;
|
|
278
|
-
}
|
|
279
|
-
else if (Object.hasOwnProperty.call(item, key)) {
|
|
280
|
-
value = item[key];
|
|
281
|
-
}
|
|
282
|
-
else if (key.includes(".")) {
|
|
283
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
284
|
-
return getNestedValues(key, item);
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
value = null;
|
|
288
|
-
}
|
|
289
|
-
// because `value` can also be undefined
|
|
290
|
-
if (value == null) {
|
|
291
|
-
return [];
|
|
292
|
-
}
|
|
293
|
-
if (Array.isArray(value)) {
|
|
294
|
-
return value;
|
|
295
|
-
}
|
|
296
|
-
return [String(value)];
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Given path: "foo.bar.baz"
|
|
300
|
-
* And item: {foo: {bar: {baz: 'buzz'}}}
|
|
301
|
-
* -> 'buzz'
|
|
302
|
-
* @param path a dot-separated set of keys
|
|
303
|
-
* @param item the item to get the value from
|
|
304
|
-
*/
|
|
305
|
-
function getNestedValues(path, item) {
|
|
306
|
-
var keys = path.split(".");
|
|
307
|
-
var values = [item];
|
|
308
|
-
for (var i = 0, I = keys.length; i < I; i++) {
|
|
309
|
-
var nestedKey = keys[i];
|
|
310
|
-
var nestedValues = [];
|
|
311
|
-
for (var j = 0, J = values.length; j < J; j++) {
|
|
312
|
-
var nestedItem = values[j];
|
|
313
|
-
if (nestedItem == null)
|
|
314
|
-
continue;
|
|
315
|
-
if (Object.hasOwnProperty.call(nestedItem, nestedKey)) {
|
|
316
|
-
var nestedValue = nestedItem[nestedKey];
|
|
317
|
-
if (nestedValue != null) {
|
|
318
|
-
nestedValues.push(nestedValue);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
else if (nestedKey === "*") {
|
|
322
|
-
// ensure that values is an array
|
|
323
|
-
nestedValues = nestedValues.concat(nestedItem);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
values = nestedValues;
|
|
327
|
-
}
|
|
328
|
-
if (Array.isArray(values[0])) {
|
|
329
|
-
// keep allowing the implicit wildcard for an array of strings at the end of
|
|
330
|
-
// the path; don't use `.flat()` because that's not available in node.js v10
|
|
331
|
-
var result = [];
|
|
332
|
-
return result.concat.apply(result, values);
|
|
333
|
-
}
|
|
334
|
-
// Based on our logic it should be an array of strings by now...
|
|
335
|
-
// assuming the user's path terminated in strings
|
|
336
|
-
return values;
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Gets all the values for the given keys in the given item and returns an array of those values
|
|
340
|
-
* @param item - the item from which the values will be retrieved
|
|
341
|
-
* @param keys - the keys to use to retrieve the values
|
|
342
|
-
* @return objects with {itemValue, attributes}
|
|
343
|
-
*/
|
|
344
|
-
function getAllValuesToRank(item, keys) {
|
|
345
|
-
var allValues = [];
|
|
346
|
-
for (var j = 0, J = keys.length; j < J; j++) {
|
|
347
|
-
var key = keys[j];
|
|
348
|
-
var attributes = getKeyAttributes(key);
|
|
349
|
-
var itemValues = getItemValues(item, key);
|
|
350
|
-
for (var i = 0, I = itemValues.length; i < I; i++) {
|
|
351
|
-
allValues.push({
|
|
352
|
-
itemValue: itemValues[i],
|
|
353
|
-
attributes: attributes,
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
return allValues;
|
|
358
|
-
}
|
|
359
|
-
var defaultKeyAttributes = {
|
|
360
|
-
maxRanking: Infinity,
|
|
361
|
-
minRanking: -Infinity,
|
|
362
|
-
};
|
|
363
|
-
/**
|
|
364
|
-
* Gets all the attributes for the given key
|
|
365
|
-
* @param key - the key from which the attributes will be retrieved
|
|
366
|
-
* @return object containing the key's attributes
|
|
367
|
-
*/
|
|
368
|
-
function getKeyAttributes(key) {
|
|
369
|
-
if (typeof key === "string") {
|
|
370
|
-
return defaultKeyAttributes;
|
|
371
|
-
}
|
|
372
|
-
return tslib_1.__assign(tslib_1.__assign({}, defaultKeyAttributes), key);
|
|
373
|
-
}
|
|
374
|
-
exports.default = matchSorter;
|
package/mbToBytes.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mbToBytes = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Megabytes to bytes
|
|
6
|
-
*
|
|
7
|
-
* @category format
|
|
8
|
-
*/
|
|
9
|
-
var mbToBytes = function (bytes) { return bytes * 1000 * 1000; };
|
|
10
|
-
exports.mbToBytes = mbToBytes;
|
|
11
|
-
exports.default = exports.mbToBytes;
|
package/mergeObjects.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeObjects = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var isObject_1 = require("./isObject");
|
|
6
|
-
/**
|
|
7
|
-
* Merge two or more objects together. It mutates the target object.
|
|
8
|
-
*
|
|
9
|
-
* @category objects
|
|
10
|
-
* @see https://stackoverflow.com/a/46973278/1938970
|
|
11
|
-
*/
|
|
12
|
-
var mergeObjects = function (target) {
|
|
13
|
-
var sources = [];
|
|
14
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
15
|
-
sources[_i - 1] = arguments[_i];
|
|
16
|
-
}
|
|
17
|
-
if (!sources.length) {
|
|
18
|
-
return target;
|
|
19
|
-
}
|
|
20
|
-
var source = sources.shift();
|
|
21
|
-
if (source === undefined) {
|
|
22
|
-
return target;
|
|
23
|
-
}
|
|
24
|
-
if ((0, isObject_1.isObject)(target) && (0, isObject_1.isObject)(source)) {
|
|
25
|
-
Object.keys(source).forEach(function (_key) {
|
|
26
|
-
var key = _key;
|
|
27
|
-
if ((0, isObject_1.isObject)(source[key])) {
|
|
28
|
-
if (!target[key]) {
|
|
29
|
-
// @ts-expect-error FIXME: ...
|
|
30
|
-
target[key] = {};
|
|
31
|
-
}
|
|
32
|
-
(0, exports.mergeObjects)(target[key], source[key]);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
target[key] = source[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
return exports.mergeObjects.apply(void 0, tslib_1.__spreadArray([target], sources, false));
|
|
40
|
-
};
|
|
41
|
-
exports.mergeObjects = mergeObjects;
|
package/mergeUrlQueryParams.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeUrlQueryParams = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var isNull_1 = tslib_1.__importDefault(require("./isNull"));
|
|
6
|
-
/**
|
|
7
|
-
* Merge query parameters objects, it *mutates* the first given object argument
|
|
8
|
-
*
|
|
9
|
-
* @category location
|
|
10
|
-
* @pure
|
|
11
|
-
*/
|
|
12
|
-
function mergeUrlQueryParams(oldParams, newParams) {
|
|
13
|
-
if (oldParams === void 0) { oldParams = {}; }
|
|
14
|
-
if (newParams === void 0) { newParams = {}; }
|
|
15
|
-
for (var key in newParams) {
|
|
16
|
-
var value = newParams[key];
|
|
17
|
-
if (oldParams[key] && (0, isNull_1.default)(value)) {
|
|
18
|
-
delete oldParams[key];
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
oldParams[key] = value;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return oldParams;
|
|
25
|
-
}
|
|
26
|
-
exports.mergeUrlQueryParams = mergeUrlQueryParams;
|
|
27
|
-
exports.default = mergeUrlQueryParams;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.moveSortableArrayItemByKey = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
/**
|
|
6
|
-
* Move item from one place to another in a sortable array of objects, re-ordering
|
|
7
|
-
* the array accrodingly (no swapping of position).
|
|
8
|
-
* This is useful for drag and drop functionalities
|
|
9
|
-
*
|
|
10
|
-
* @category arrays, dnd
|
|
11
|
-
*/
|
|
12
|
-
function moveSortableArrayItemByKey(items, key, fromItem, toItem) {
|
|
13
|
-
var itemsKeys = items.map(function (item) { return item[key]; });
|
|
14
|
-
var idxFrom = itemsKeys.indexOf(fromItem[key]);
|
|
15
|
-
var idxTo = itemsKeys.indexOf(toItem[key]);
|
|
16
|
-
var item = items.splice(idxFrom, 1)[0];
|
|
17
|
-
items.splice(idxTo, 0, item);
|
|
18
|
-
return tslib_1.__spreadArray([], items, true);
|
|
19
|
-
}
|
|
20
|
-
exports.moveSortableArrayItemByKey = moveSortableArrayItemByKey;
|
|
21
|
-
exports.default = moveSortableArrayItemByKey;
|
package/noop.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.noop = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* No operation function
|
|
6
|
-
*
|
|
7
|
-
* @category native
|
|
8
|
-
*/
|
|
9
|
-
var noop = function () { return void 0; };
|
|
10
|
-
exports.noop = noop;
|
|
11
|
-
exports.default = exports.noop;
|
package/normaliseUrl.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normaliseUrl = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var removeTrailingSlash_1 = tslib_1.__importDefault(require("./removeTrailingSlash"));
|
|
6
|
-
/**
|
|
7
|
-
* Normalise URL, it works both for absolute and relative URLs
|
|
8
|
-
*
|
|
9
|
-
* - replaces too many consecutive slashes (except `http{s}://`)
|
|
10
|
-
* - removes the trailing slash
|
|
11
|
-
*
|
|
12
|
-
* @category location
|
|
13
|
-
* @see https://stackoverflow.com/a/40649435/1938970
|
|
14
|
-
*/
|
|
15
|
-
function normaliseUrl(absoluteUrl) {
|
|
16
|
-
if (absoluteUrl === void 0) { absoluteUrl = ""; }
|
|
17
|
-
return (0, removeTrailingSlash_1.default)(absoluteUrl.replace(/(:\/\/)|(\/)+/g, "$1$2"));
|
|
18
|
-
}
|
|
19
|
-
exports.normaliseUrl = normaliseUrl;
|
|
20
|
-
exports.default = normaliseUrl;
|
package/normaliseUrlPathname.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normaliseUrlPathname = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var removeTrailingSlash_1 = tslib_1.__importDefault(require("./removeTrailingSlash"));
|
|
6
|
-
/**
|
|
7
|
-
* Normalise URL pathname (relative URL)
|
|
8
|
-
*
|
|
9
|
-
* - replaces too many consecutive slashes
|
|
10
|
-
* - removes the trailing slash
|
|
11
|
-
*
|
|
12
|
-
* @category location
|
|
13
|
-
*/
|
|
14
|
-
function normaliseUrlPathname(pathname) {
|
|
15
|
-
if (pathname === void 0) { pathname = ""; }
|
|
16
|
-
return (0, removeTrailingSlash_1.default)(pathname.replace(/\/+/g, "/"));
|
|
17
|
-
}
|
|
18
|
-
exports.normaliseUrlPathname = normaliseUrlPathname;
|
|
19
|
-
exports.default = normaliseUrlPathname;
|
package/objectOmit.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectOmit = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Omit object properties by removing the given keys, it returns a
|
|
6
|
-
* new object.
|
|
7
|
-
*
|
|
8
|
-
* NOTE: most of the time using a normal [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) is enough,
|
|
9
|
-
* use this utility only when it makes sense.
|
|
10
|
-
*
|
|
11
|
-
* @category objects
|
|
12
|
-
*/
|
|
13
|
-
function objectOmit(object, keys) {
|
|
14
|
-
return Object.keys(object).reduce(function (output, key) {
|
|
15
|
-
if (!keys.includes(key)) {
|
|
16
|
-
output[key] =
|
|
17
|
-
object[key];
|
|
18
|
-
}
|
|
19
|
-
return output;
|
|
20
|
-
}, {});
|
|
21
|
-
}
|
|
22
|
-
exports.objectOmit = objectOmit;
|
|
23
|
-
exports.default = objectOmit;
|
package/objectPick.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectPick = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Pick object properties by selecting only the given keys, it returns a
|
|
6
|
-
* new object.
|
|
7
|
-
*
|
|
8
|
-
* @category objects
|
|
9
|
-
*/
|
|
10
|
-
function objectPick(object, keys) {
|
|
11
|
-
var output = {};
|
|
12
|
-
var len = keys.length;
|
|
13
|
-
while (len--) {
|
|
14
|
-
output[keys[len]] = object[keys[len]];
|
|
15
|
-
}
|
|
16
|
-
return output;
|
|
17
|
-
}
|
|
18
|
-
exports.objectPick = objectPick;
|
|
19
|
-
exports.default = objectPick;
|
package/parseCookie.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCookie = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Try decoding a string using a decoding function.
|
|
6
|
-
*/
|
|
7
|
-
function tryDecode(str, decode) {
|
|
8
|
-
try {
|
|
9
|
-
return decode(str);
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
return str;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Parse a cookie header.
|
|
17
|
-
*
|
|
18
|
-
* Parse the given cookie header string into an object
|
|
19
|
-
* The object has the various cookies as keys(names) => values
|
|
20
|
-
*
|
|
21
|
-
* @category cookie
|
|
22
|
-
*/
|
|
23
|
-
function parseCookie(str, attributes) {
|
|
24
|
-
if (attributes === void 0) { attributes = {}; }
|
|
25
|
-
if (typeof str !== "string") {
|
|
26
|
-
throw new TypeError("argument str must be a string");
|
|
27
|
-
}
|
|
28
|
-
var obj = {};
|
|
29
|
-
var pairs = str.split(";");
|
|
30
|
-
var _a = attributes.decode, decode = _a === void 0 ? decodeURIComponent : _a;
|
|
31
|
-
for (var i = 0; i < pairs.length; i++) {
|
|
32
|
-
var pair = pairs[i];
|
|
33
|
-
var index = pair.indexOf("=");
|
|
34
|
-
// skip things that don't look like key=value
|
|
35
|
-
if (index < 0) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
var key = pair.substring(0, index).trim();
|
|
39
|
-
// only assign once
|
|
40
|
-
if (undefined == obj[key]) {
|
|
41
|
-
var val = pair.substring(index + 1, pair.length).trim();
|
|
42
|
-
// quoted values
|
|
43
|
-
if (val[0] === '"') {
|
|
44
|
-
val = val.slice(1, -1);
|
|
45
|
-
}
|
|
46
|
-
obj[key] = tryDecode(val, decode);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return obj;
|
|
50
|
-
}
|
|
51
|
-
exports.parseCookie = parseCookie;
|
|
52
|
-
exports.default = parseCookie;
|
package/parseURL.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseURL = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Solution without DOM or specific env native methods
|
|
6
|
-
*
|
|
7
|
-
* @category location
|
|
8
|
-
* @see https://stackoverflow.com/a/21553982/1938970
|
|
9
|
-
*/
|
|
10
|
-
function parseURL(url) {
|
|
11
|
-
var match = url.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
12
|
-
return (match && {
|
|
13
|
-
href: url,
|
|
14
|
-
protocol: match[1],
|
|
15
|
-
host: match[2],
|
|
16
|
-
hostname: match[3],
|
|
17
|
-
port: match[4],
|
|
18
|
-
pathname: match[5],
|
|
19
|
-
search: match[6],
|
|
20
|
-
hash: match[7],
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
exports.parseURL = parseURL;
|
|
24
|
-
exports.default = parseURL;
|
package/quaranteneProps.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.quaranteneProps = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* @category impl
|
|
6
|
-
* @usage
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* const { _: { onKeyDown }, myOwnProp, ...rest } = quaranteneProps([
|
|
10
|
-
* "onPointerLeave",
|
|
11
|
-
* "onPointerMove",
|
|
12
|
-
* "onClick",
|
|
13
|
-
* "onPointerDown",
|
|
14
|
-
* "onPointerUp",
|
|
15
|
-
* "onKeyDown",
|
|
16
|
-
* ]);
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
function quaranteneProps(props, propsKeysToQuarantene) {
|
|
20
|
-
// approach 1)
|
|
21
|
-
var healthyProps = {
|
|
22
|
-
_: {},
|
|
23
|
-
};
|
|
24
|
-
for (var key in props) {
|
|
25
|
-
var prop = props[key];
|
|
26
|
-
if (propsKeysToQuarantene.includes(key)) {
|
|
27
|
-
healthyProps._[key] = prop;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
// @ts-expect-error nevermind
|
|
31
|
-
healthyProps[key] = prop;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return healthyProps;
|
|
35
|
-
}
|
|
36
|
-
exports.quaranteneProps = quaranteneProps;
|
|
37
|
-
exports.default = quaranteneProps;
|