@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
|
@@ -1,68 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @category responsive
|
|
3
|
+
*/ /**
|
|
4
|
+
* @category responsive
|
|
5
|
+
*/ export function getMediaQueryWidthResolvers(customBreakpoints) {
|
|
6
|
+
const breakpoints = {
|
|
7
|
+
xs: 0,
|
|
8
|
+
...customBreakpoints
|
|
9
|
+
};
|
|
10
|
+
const sortedBreakpointsNames = Object.keys(breakpoints).map((key)=>{
|
|
11
|
+
const br = key;
|
|
12
|
+
return [
|
|
13
|
+
br,
|
|
14
|
+
breakpoints[br]
|
|
15
|
+
];
|
|
16
|
+
}).sort((a, b)=>a[1] - b[1]).map((item)=>item[0]);
|
|
17
|
+
const getNextBreakpoint = (breakpoint)=>{
|
|
18
|
+
const index = sortedBreakpointsNames.indexOf(breakpoint);
|
|
12
19
|
return sortedBreakpointsNames[index + 1];
|
|
13
20
|
};
|
|
14
21
|
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var min = function (br) { return "(min-width: ".concat(breakpoints[br], "px)"); };
|
|
22
|
+
* It behaves the same as `(min-width: ${value}px)`
|
|
23
|
+
* where value is the given breakpoint value.
|
|
24
|
+
* For ease of use this can be used both as a function `min("md")` and as an
|
|
25
|
+
* object literal `min.md`.
|
|
26
|
+
*/ const min = (br)=>`(min-width: ${breakpoints[br]}px)`;
|
|
21
27
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var max = function (br) { return "(max-width: ".concat(breakpoints[br] - 0.02, "px)"); };
|
|
28
|
+
* It behaves the same as `(max-width: ${value}px)`
|
|
29
|
+
* where value is the given breakpoint value.
|
|
30
|
+
* For ease of use this can be used both as a function `max("md")` and as an
|
|
31
|
+
* object literal `max.md`.
|
|
32
|
+
*/ const max = (br)=>`(max-width: ${breakpoints[br] - 0.02}px)`;
|
|
28
33
|
/**
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var up = min;
|
|
34
|
+
* It behaves the same as `min`
|
|
35
|
+
* @inheritdoc {max}
|
|
36
|
+
*/ const up = min;
|
|
33
37
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var brNext = getNextBreakpoint(br);
|
|
38
|
+
* It behaves similarly to `max` but you will use the "next" breakpoint,
|
|
39
|
+
* specifying CSS that will apply from the given breakpoint and down.
|
|
40
|
+
*/ const down = (br)=>{
|
|
41
|
+
const brNext = getNextBreakpoint(br);
|
|
39
42
|
// TODO: if br does not exists otherwise throw Error
|
|
40
|
-
return brNext &&
|
|
43
|
+
return brNext && `(max-width: ${breakpoints[brNext] - 0.02}px)`;
|
|
41
44
|
};
|
|
42
45
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var between = function (br1, br2) {
|
|
46
|
+
* Media query between the two given breakpoints
|
|
47
|
+
*/ const between = (br1, br2)=>{
|
|
46
48
|
br2 = br2 || getNextBreakpoint(br1);
|
|
47
|
-
return br2
|
|
48
|
-
? "(min-width: ".concat(breakpoints[br1], "px) and (max-width: ").concat(breakpoints[br2] - 0.02, "px)")
|
|
49
|
-
: min(br1);
|
|
49
|
+
return br2 ? `(min-width: ${breakpoints[br1]}px) and (max-width: ${breakpoints[br2] - 0.02}px)` : min(br1);
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
var brNext = getNextBreakpoint(br);
|
|
52
|
+
* Media query to apply from the given breakpoint until the next, just for its
|
|
53
|
+
* full range
|
|
54
|
+
*/ const only = (br)=>{
|
|
55
|
+
const brNext = getNextBreakpoint(br);
|
|
57
56
|
return brNext ? between(br, brNext) : min(br);
|
|
58
57
|
};
|
|
59
58
|
return {
|
|
60
|
-
max
|
|
61
|
-
min
|
|
62
|
-
down
|
|
63
|
-
up
|
|
64
|
-
between
|
|
65
|
-
only
|
|
59
|
+
max,
|
|
60
|
+
min,
|
|
61
|
+
down,
|
|
62
|
+
up,
|
|
63
|
+
between,
|
|
64
|
+
only
|
|
66
65
|
};
|
|
67
66
|
}
|
|
68
67
|
export default getMediaQueryWidthResolvers;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { type GetMediaQueryWidthResolversBreakpoints } from "./getMediaQueryWidthResolvers";
|
|
2
|
+
/**
|
|
3
|
+
* @category responsive
|
|
4
|
+
* @category tailwind
|
|
5
|
+
*/
|
|
2
6
|
export declare function getMediaQueryWidthTailwindScreens(breakpoints: GetMediaQueryWidthResolversBreakpoints): Record<string, {
|
|
3
7
|
raw: string;
|
|
4
8
|
}>;
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
import { getMediaQueryWidthResolvers
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getMediaQueryWidthResolvers } from "./getMediaQueryWidthResolvers";
|
|
2
|
+
/**
|
|
3
|
+
* @category responsive
|
|
4
|
+
* @category tailwind
|
|
5
|
+
*/ export function getMediaQueryWidthTailwindScreens(breakpoints) {
|
|
6
|
+
const mqWidthResolvers = getMediaQueryWidthResolvers(breakpoints);
|
|
4
7
|
// Object.keys(breakpoints).reduce((screens, br) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for
|
|
8
|
+
const screens = Object.keys(breakpoints).reduce((output, br, idx)=>{
|
|
9
|
+
const brNext = Object.keys(breakpoints)[idx + 1];
|
|
10
|
+
for(const resolverName in mqWidthResolvers){
|
|
8
11
|
// this line is just for typescript..
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const resolver = resolverName;
|
|
13
|
+
const resolverFn = mqWidthResolvers[resolver];
|
|
14
|
+
const raw = resolverFn(br);
|
|
12
15
|
if (raw) {
|
|
13
16
|
if (resolverName === "min") {
|
|
14
|
-
output[
|
|
17
|
+
output[`@${br}`] = {
|
|
18
|
+
raw
|
|
19
|
+
};
|
|
15
20
|
}
|
|
16
21
|
if (resolverName === "between") {
|
|
17
|
-
if (brNext)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
else {
|
|
21
|
-
output[
|
|
22
|
+
if (brNext) output[`@${resolverName}-${br}_${brNext}`] = {
|
|
23
|
+
raw
|
|
24
|
+
};
|
|
25
|
+
} else {
|
|
26
|
+
output[`@${resolverName}-${br}`] = {
|
|
27
|
+
raw
|
|
28
|
+
};
|
|
22
29
|
}
|
|
23
30
|
}
|
|
24
31
|
}
|
package/getNonce.mjs
CHANGED
|
@@ -2,8 +2,7 @@ import { isUndefined } from "./isUndefined";
|
|
|
2
2
|
/**
|
|
3
3
|
* @category security
|
|
4
4
|
* @see https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/nonce.ts
|
|
5
|
-
*/
|
|
6
|
-
export function getNonce() {
|
|
5
|
+
*/ export function getNonce() {
|
|
7
6
|
return isUndefined(__webpack_nonce__) ? null : __webpack_nonce__;
|
|
8
7
|
}
|
|
9
8
|
export default getNonce;
|
package/getParamAmong.d.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @category location
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
8
|
+
* @param raw The _raw_ query parameter
|
|
9
|
+
* @param allowedValues The list of values (as strings) that the parameter can
|
|
10
|
+
* have, if not one of them `null` is returned
|
|
10
11
|
*/
|
|
11
12
|
export declare function getParamAmong<T extends string[]>(raw?: string | string[], allowedValues?: T): T[number] | null;
|
|
12
13
|
export default getParamAmong;
|
package/getParamAmong.mjs
CHANGED
|
@@ -6,12 +6,11 @@ import getParamAsString from "./getParamAsString";
|
|
|
6
6
|
*
|
|
7
7
|
* @category location
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
|
|
12
|
-
export function getParamAmong(raw, allowedValues) {
|
|
13
|
-
|
|
14
|
-
var string = getParamAsString(raw);
|
|
9
|
+
* @param raw The _raw_ query parameter
|
|
10
|
+
* @param allowedValues The list of values (as strings) that the parameter can
|
|
11
|
+
* have, if not one of them `null` is returned
|
|
12
|
+
*/ export function getParamAmong(raw, allowedValues = []) {
|
|
13
|
+
const string = getParamAsString(raw);
|
|
15
14
|
return allowedValues.includes(string) ? string : null;
|
|
16
15
|
}
|
|
17
16
|
export default getParamAmong;
|
package/getParamAsInt.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @category location
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
8
|
+
* @param raw The _raw_ query parameter
|
|
9
|
+
* @param fallback Fallback number, we return `null` if not provided
|
|
10
10
|
*/
|
|
11
11
|
export declare function getParamAsInt<TFallback extends number | null | undefined>(raw?: string | string[], fallback?: TFallback): number | TFallback;
|
|
12
12
|
export default getParamAsInt;
|
package/getParamAsInt.mjs
CHANGED
|
@@ -6,12 +6,10 @@ import getParamAsString from "./getParamAsString";
|
|
|
6
6
|
*
|
|
7
7
|
* @category location
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
if (fallback === void 0) { fallback = null; }
|
|
14
|
-
var string = getParamAsString(raw);
|
|
9
|
+
* @param raw The _raw_ query parameter
|
|
10
|
+
* @param fallback Fallback number, we return `null` if not provided
|
|
11
|
+
*/ export function getParamAsInt(raw, fallback = null) {
|
|
12
|
+
const string = getParamAsString(raw);
|
|
15
13
|
if (string) {
|
|
16
14
|
return parseInt(string, 10);
|
|
17
15
|
}
|
package/getParamAsString.d.ts
CHANGED
package/getParamAsString.mjs
CHANGED
|
@@ -6,9 +6,8 @@ import isArray from "./isArray";
|
|
|
6
6
|
*
|
|
7
7
|
* @category location
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
10
|
-
*/
|
|
11
|
-
export function getParamAsString(raw) {
|
|
9
|
+
* @param raw The _raw_ query parameter
|
|
10
|
+
*/ export function getParamAsString(raw) {
|
|
12
11
|
return (isArray(raw) ? raw[0] : raw) || "";
|
|
13
12
|
}
|
|
14
13
|
export default getParamAsString;
|
package/getType.d.ts
CHANGED
|
@@ -14,9 +14,6 @@ export type PlainObject = Record<string | number | symbol, any>;
|
|
|
14
14
|
export type TypeGuard<A, B extends A> = (payload: A) => payload is B;
|
|
15
15
|
/**
|
|
16
16
|
* Returns the object type of the given payload
|
|
17
|
-
*
|
|
18
|
-
* @param {*} payload
|
|
19
|
-
* @returns {string}
|
|
20
17
|
*/
|
|
21
18
|
export declare function getType(payload: any): string;
|
|
22
19
|
export default getType;
|
package/getType.mjs
CHANGED
|
@@ -6,14 +6,9 @@
|
|
|
6
6
|
* - `isFormData`
|
|
7
7
|
* - `isInt`
|
|
8
8
|
* - `isFloat`
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
9
|
+
*/ /**
|
|
11
10
|
* Returns the object type of the given payload
|
|
12
|
-
|
|
13
|
-
* @param {*} payload
|
|
14
|
-
* @returns {string}
|
|
15
|
-
*/
|
|
16
|
-
export function getType(payload) {
|
|
11
|
+
*/ export function getType(payload) {
|
|
17
12
|
return Object.prototype.toString.call(payload).slice(8, -1);
|
|
18
13
|
}
|
|
19
14
|
export default getType;
|
package/getUrlHashParams.mjs
CHANGED
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
* string or, if not provided, failling back reading the `location.hash`
|
|
4
4
|
*
|
|
5
5
|
* @category location
|
|
6
|
-
*/
|
|
7
|
-
export function getUrlHashParams(hash) {
|
|
8
|
-
if (hash === void 0) { hash = ""; }
|
|
6
|
+
*/ export function getUrlHashParams(hash = "") {
|
|
9
7
|
hash = hash || location.hash;
|
|
10
|
-
|
|
8
|
+
const hashParts = hash.split("?");
|
|
11
9
|
if (hashParts.length >= 1) {
|
|
12
10
|
return Object.fromEntries(new URLSearchParams(hashParts[1]));
|
|
13
11
|
}
|
package/getUrlHashPathname.mjs
CHANGED
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
* back reading the `location.hash`
|
|
5
5
|
*
|
|
6
6
|
* @category location
|
|
7
|
-
*/
|
|
8
|
-
export function getUrlHashPathname(hash) {
|
|
9
|
-
if (hash === void 0) { hash = ""; }
|
|
7
|
+
*/ export function getUrlHashPathname(hash = "") {
|
|
10
8
|
hash = hash || location.hash;
|
|
11
9
|
return hash.split("?")[0].replace(/^#\//, "");
|
|
12
10
|
}
|
package/getUrlPathnameParts.mjs
CHANGED
|
@@ -8,13 +8,8 @@ import isBrowser from "./isBrowser";
|
|
|
8
8
|
* `[locale, prefix, collection, slug]`
|
|
9
9
|
*
|
|
10
10
|
* @category location
|
|
11
|
-
*/
|
|
12
|
-
export function getUrlPathnameParts(pathname) {
|
|
13
|
-
if (pathname === void 0) { pathname = ""; }
|
|
11
|
+
*/ export function getUrlPathnameParts(pathname = "") {
|
|
14
12
|
pathname = pathname || isBrowser ? location.pathname : "";
|
|
15
|
-
return pathname
|
|
16
|
-
.replace(/^\//, "")
|
|
17
|
-
.split("/")
|
|
18
|
-
.filter(function (part) { return part; });
|
|
13
|
+
return pathname.replace(/^\//, "").split("/").filter((part)=>part);
|
|
19
14
|
}
|
|
20
15
|
export default getUrlPathnameParts;
|
package/getUrlQueryParams.d.ts
CHANGED
|
@@ -4,10 +4,9 @@ import { type AnyQueryParams } from "./location";
|
|
|
4
4
|
*
|
|
5
5
|
* @category location
|
|
6
6
|
* @param url A URL which contains a `?`, e.g. `?myparam=x` or `https://a.com?myparams=x`.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* the `href` of a `<a href="...">` HTML tag.
|
|
7
|
+
* If not provided it defaults reading the current URL query string with
|
|
8
|
+
* `location.search`. Through this argument you can use this same function to
|
|
9
|
+
* parse, for instance, the query params of the `href` of a `<a href="...">` HTML tag.
|
|
11
10
|
*
|
|
12
11
|
*/
|
|
13
12
|
export declare function getUrlQueryParams<T extends NonNullable<AnyQueryParams>>(url?: string): T;
|
package/getUrlQueryParams.mjs
CHANGED
|
@@ -4,34 +4,22 @@ import isBrowser from "./isBrowser";
|
|
|
4
4
|
*
|
|
5
5
|
* @category location
|
|
6
6
|
* @param url A URL which contains a `?`, e.g. `?myparam=x` or `https://a.com?myparams=x`.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* the `href` of a `<a href="...">` HTML tag.
|
|
7
|
+
* If not provided it defaults reading the current URL query string with
|
|
8
|
+
* `location.search`. Through this argument you can use this same function to
|
|
9
|
+
* parse, for instance, the query params of the `href` of a `<a href="...">` HTML tag.
|
|
11
10
|
*
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var params = {};
|
|
16
|
-
var search = url
|
|
17
|
-
? (_a = url.split("?")) === null || _a === void 0 ? void 0 : _a[1]
|
|
18
|
-
: isBrowser
|
|
19
|
-
? location.search.substring(1)
|
|
20
|
-
: "";
|
|
11
|
+
*/ export function getUrlQueryParams(url) {
|
|
12
|
+
let params = {};
|
|
13
|
+
const search = url ? url.split("?")?.[1] : isBrowser ? location.search.substring(1) : "";
|
|
21
14
|
if (!search) {
|
|
22
15
|
return {};
|
|
23
16
|
}
|
|
24
17
|
try {
|
|
25
18
|
// @see https://stackoverflow.com/a/8649003/1938970
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return key === "" ? value : decodeURIComponent(value);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
catch (e) {
|
|
34
|
-
// do nothing or warn on process.env["NODE_ENV"] !== "production"
|
|
19
|
+
const paramsAsObj = `{"${search.replace(/&/g, '","').replace(/=/g, '":"')}"}`;
|
|
20
|
+
params = JSON.parse(paramsAsObj, (key, value)=>key === "" ? value : decodeURIComponent(value));
|
|
21
|
+
} catch (e) {
|
|
22
|
+
// do nothing or warn on process.env["NODE_ENV"] !== "production"
|
|
35
23
|
}
|
|
36
24
|
return params;
|
|
37
25
|
}
|
package/imgEmptyPixel.mjs
CHANGED
|
@@ -2,6 +2,5 @@
|
|
|
2
2
|
* Empty img pixel as a string to inline
|
|
3
3
|
*
|
|
4
4
|
* @category img
|
|
5
|
-
*/
|
|
6
|
-
export var imgEmptyPixel = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
|
|
5
|
+
*/ export const imgEmptyPixel = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=";
|
|
7
6
|
export default imgEmptyPixel;
|
package/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { changeUrlPath } from "./changeUrlPath";
|
|
|
10
10
|
export { chunkByChunks } from "./chunkByChunks";
|
|
11
11
|
export { chunkBySize } from "./chunkBySize";
|
|
12
12
|
export { clamp } from "./clamp";
|
|
13
|
-
export { clsx } from "./clsx";
|
|
13
|
+
export { clsx, type ClsxClassValue } from "./clsx";
|
|
14
14
|
export { convertRange } from "./convertRange";
|
|
15
15
|
export { type CookieAttributesClient, type CookieAttributesServer, } from "./cookie";
|
|
16
16
|
export { createPalette } from "./createPalette";
|
|
@@ -131,4 +131,7 @@ export { uuid } from "./uuid";
|
|
|
131
131
|
export { uuidNumeric } from "./uuidNumeric";
|
|
132
132
|
export { wait } from "./wait";
|
|
133
133
|
export type { AnythingFalsy, KeysStartsWith, KeysTailsStartsWith, PickStartsWith, PickStartsWithTails, } from "./types";
|
|
134
|
-
|
|
134
|
+
/**
|
|
135
|
+
* These types should not be documented by using [`excludeExternals` TypeDoc flag](https://typedoc.org/options/input/#excludeexternals)
|
|
136
|
+
*/
|
|
137
|
+
export type { Primitive, Class, Constructor, TypedArray, Observer, ObservableLike, Except, Writable, Merge, MergeDeep, MergeExclusive, RequireAtLeastOne, RequireExactlyOne, RequireAllOrNone, PartialDeep, ReadonlyDeep, LiteralUnion, Opaque, InvariantOf, SetOptional, SetRequired, ValueOf, ConditionalKeys, ConditionalPick, ConditionalExcept, UnionToIntersection, LiteralToPrimitive, Stringified, IterableElement, Entry, Exact, Entries, SetReturnType, Simplify, Get, StringKeyOf, Schema, Jsonify, JsonPrimitive, JsonObject, JsonArray, JsonValue, Promisable, AsyncReturnType, Asyncify, Trim, Split, Includes, Join, LastArrayElement, FixedLengthArray, MultidimensionalArray, MultidimensionalReadonlyArray, PositiveInfinity, NegativeInfinity, Finite, Integer, Float, NegativeFloat, Negative, NonNegative, NegativeInteger, NonNegativeInteger, CamelCase, CamelCasedProperties, CamelCasedPropertiesDeep, KebabCase, KebabCasedProperties, KebabCasedPropertiesDeep, PascalCase, PascalCasedProperties, PascalCasedPropertiesDeep, SnakeCase, SnakeCasedProperties, SnakeCasedPropertiesDeep, ScreamingSnakeCase, DelimiterCase, DelimiterCasedProperties, DelimiterCasedPropertiesDeep, PackageJson, TsConfigJson, SetNonNullable, Spread, PartialOnUndefinedDeep, OptionalKeysOf, HasOptionalKeys, RequiredKeysOf, HasRequiredKeys, UnwrapOpaque, EmptyObject, IsEmptyObject, TupleToUnion, OmitIndexSignature, PickIndexSignature, ConditionalPickDeep, } from "type-fest";
|
package/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ export { convertRange } from "./convertRange";
|
|
|
15
15
|
export { createPalette } from "./createPalette";
|
|
16
16
|
export { debounce } from "./debounce";
|
|
17
17
|
export { debounceRaf } from "./debounceRaf";
|
|
18
|
-
export { debouncePromise
|
|
18
|
+
export { debouncePromise } from "./debouncePromise";
|
|
19
19
|
export { decode } from "./decode";
|
|
20
20
|
export { Defer } from "./Defer";
|
|
21
21
|
export { Emitter } from "./Emitter";
|
|
@@ -34,7 +34,7 @@ export { getNonce } from "./getNonce";
|
|
|
34
34
|
export { getParamAmong } from "./getParamAmong";
|
|
35
35
|
export { getParamAsInt } from "./getParamAsInt";
|
|
36
36
|
export { getParamAsString } from "./getParamAsString";
|
|
37
|
-
export { getType
|
|
37
|
+
export { getType } from "./getType";
|
|
38
38
|
export { getUrlHashParams } from "./getUrlHashParams";
|
|
39
39
|
export { getUrlHashPathname } from "./getUrlHashPathname";
|
|
40
40
|
export { getUrlPathnameParts } from "./getUrlPathnameParts";
|
package/invariant.mjs
CHANGED
|
@@ -14,19 +14,17 @@
|
|
|
14
14
|
* @param message A string or a function that returns a string
|
|
15
15
|
* @param lib The library name to show in the error message prefix. When `lib` is also specified it outputs `[lib:prefix]: the message`, otherwise just `[lib|prefix]: the message`)
|
|
16
16
|
* @param prefix The library name to show in the error message prefix. When `lib` is also specified it outputs `[lib:prefix]: the message`, otherwise just `[lib|prefix]: the message`)
|
|
17
|
-
*/
|
|
18
|
-
export function invariant(condition, message, lib, prefix) {
|
|
17
|
+
*/ export function invariant(condition, message, lib, prefix) {
|
|
19
18
|
if (process.env["NODE_ENV"] !== "production") {
|
|
20
19
|
if (condition) {
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const msgProvided = typeof message === "function" ? message() : message;
|
|
23
|
+
let msgPrefix = "";
|
|
25
24
|
if (lib && prefix) {
|
|
26
|
-
msgPrefix =
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
msgPrefix = "[".concat(lib, "] ");
|
|
25
|
+
msgPrefix = `[${lib}:${prefix}] `;
|
|
26
|
+
} else if (lib) {
|
|
27
|
+
msgPrefix = `[${lib}] `;
|
|
30
28
|
}
|
|
31
29
|
throw new Error(msgPrefix + msgProvided);
|
|
32
30
|
}
|
package/isAnyObject.mjs
CHANGED
|
@@ -3,8 +3,7 @@ import getType from "./getType";
|
|
|
3
3
|
* Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)
|
|
4
4
|
*
|
|
5
5
|
* @category is
|
|
6
|
-
*/
|
|
7
|
-
export function isAnyObject(payload) {
|
|
6
|
+
*/ export function isAnyObject(payload) {
|
|
8
7
|
return getType(payload) === "Object";
|
|
9
8
|
}
|
|
10
9
|
export default isAnyObject;
|
package/isArray.mjs
CHANGED
package/isBlob.mjs
CHANGED
package/isBoolean.mjs
CHANGED
package/isBrowser.mjs
CHANGED
package/isBrowserNow.mjs
CHANGED
package/isDate.mjs
CHANGED
|
@@ -3,8 +3,7 @@ import getType from "./getType";
|
|
|
3
3
|
* Returns whether the payload is a Date, and that the date is valid
|
|
4
4
|
*
|
|
5
5
|
* @category is
|
|
6
|
-
*/
|
|
7
|
-
export function isDate(payload) {
|
|
6
|
+
*/ export function isDate(payload) {
|
|
8
7
|
return getType(payload) === "Date" && !isNaN(payload);
|
|
9
8
|
}
|
|
10
9
|
export default isDate;
|
package/isEmptyArray.mjs
CHANGED
|
@@ -3,8 +3,7 @@ import isArray from "./isArray";
|
|
|
3
3
|
* Returns whether the payload is a an empty array
|
|
4
4
|
*
|
|
5
5
|
* @category is
|
|
6
|
-
*/
|
|
7
|
-
export function isEmptyArray(payload) {
|
|
6
|
+
*/ export function isEmptyArray(payload) {
|
|
8
7
|
return isArray(payload) && payload.length === 0;
|
|
9
8
|
}
|
|
10
9
|
export default isEmptyArray;
|
package/isEmptyObject.mjs
CHANGED
|
@@ -3,8 +3,7 @@ import isPlainObject from "./isPlainObject";
|
|
|
3
3
|
* Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)
|
|
4
4
|
*
|
|
5
5
|
* @category is
|
|
6
|
-
*/
|
|
7
|
-
export function isEmptyObject(payload) {
|
|
6
|
+
*/ export function isEmptyObject(payload) {
|
|
8
7
|
return isPlainObject(payload) && Object.keys(payload).length === 0;
|
|
9
8
|
}
|
|
10
9
|
export default isEmptyObject;
|
package/isEmptyString.mjs
CHANGED
package/isError.mjs
CHANGED
package/isExternalUrl.mjs
CHANGED
|
@@ -5,17 +5,15 @@ import isBrowser from "./isBrowser";
|
|
|
5
5
|
*
|
|
6
6
|
* @category location
|
|
7
7
|
*
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var reg = /https?:\/\/((?:[\w\d-]+\.)+[\w\d]{2,})/i;
|
|
12
|
-
var urlMatches = reg.exec(url);
|
|
8
|
+
*/ export function isExternalUrl(url, currentUrl) {
|
|
9
|
+
const reg = /https?:\/\/((?:[\w\d-]+\.)+[\w\d]{2,})/i;
|
|
10
|
+
const urlMatches = reg.exec(url);
|
|
13
11
|
// if no matches are found it means we either have an invalid URL, a relative
|
|
14
12
|
// URL or a hash link, and those are not considered externals
|
|
15
13
|
if (!urlMatches) {
|
|
16
14
|
return false;
|
|
17
15
|
}
|
|
18
16
|
currentUrl = currentUrl || isBrowser ? location.href : "";
|
|
19
|
-
return currentUrl ?
|
|
17
|
+
return currentUrl ? reg.exec(currentUrl)?.[1] !== urlMatches[1] : true;
|
|
20
18
|
}
|
|
21
19
|
export default isExternalUrl;
|
package/isFile.mjs
CHANGED