@koine/utils 1.0.26 → 1.0.29
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/{async.d.ts → Defer.d.ts} +5 -5
- package/{async.js → Defer.js} +2 -7
- package/{emitter.d.ts → Emitter.d.ts} +1 -0
- package/{emitter.js → Emitter.js} +1 -0
- package/accentSets.d.ts +16 -0
- package/accentSets.js +38 -0
- package/addOrReplaceAtIdx.d.ts +5 -0
- package/addOrReplaceAtIdx.js +19 -0
- package/arrayToLookup.d.ts +7 -0
- package/arrayToLookup.js +13 -0
- package/buildUrlQueryString.d.ts +12 -0
- package/buildUrlQueryString.js +24 -0
- package/changeUrlPath.d.ts +10 -0
- package/changeUrlPath.js +18 -0
- package/chunkByChunks.d.ts +7 -0
- package/chunkByChunks.js +37 -0
- package/chunkBySize.d.ts +6 -0
- package/chunkBySize.js +12 -0
- package/clamp.d.ts +8 -0
- package/clamp.js +10 -0
- package/clsx.d.ts +9 -0
- package/clsx.js +49 -0
- package/convertRange.d.ts +14 -0
- package/convertRange.js +16 -0
- package/cookie.d.ts +7 -26
- package/cookie.js +3 -221
- package/decode.d.ts +6 -0
- package/decode.js +10 -0
- package/encode.d.ts +6 -0
- package/encode.js +10 -0
- package/{cast.d.ts → ensureInt.d.ts} +3 -1
- package/{cast.js → ensureInt.js} +3 -4
- package/findDuplicatedIndexes.d.ts +5 -0
- package/findDuplicatedIndexes.js +14 -0
- package/getKeys.d.ts +9 -0
- package/getKeys.js +9 -0
- package/getNonce.d.ts +6 -0
- package/getNonce.js +9 -0
- package/getType.d.ts +22 -0
- package/getType.js +19 -0
- package/getUrlHashParams.d.ts +9 -0
- package/getUrlHashParams.js +16 -0
- package/getUrlHashPathname.d.ts +9 -0
- package/getUrlHashPathname.js +13 -0
- package/getUrlPathnameParts.d.ts +12 -0
- package/getUrlPathnameParts.js +20 -0
- package/getUrlQueryParams.d.ts +14 -0
- package/getUrlQueryParams.js +38 -0
- package/index.d.ts +107 -15
- package/index.js +108 -16
- package/isAnyObject.d.ts +8 -0
- package/isAnyObject.js +10 -0
- package/isArray.d.ts +7 -0
- package/isArray.js +10 -0
- package/isBlob.d.ts +7 -0
- package/isBlob.js +10 -0
- package/isBoolean.d.ts +7 -0
- package/isBoolean.js +10 -0
- package/isBrowser.d.ts +6 -0
- package/{ssr.js → isBrowser.js} +5 -2
- package/isDate.d.ts +7 -0
- package/isDate.js +10 -0
- package/isEmptyArray.d.ts +7 -0
- package/isEmptyArray.js +10 -0
- package/isEmptyObject.d.ts +9 -0
- package/isEmptyObject.js +10 -0
- package/isEmptyString.d.ts +7 -0
- package/isEmptyString.js +9 -0
- package/isError.d.ts +7 -0
- package/isError.js +10 -0
- package/isExternalUrl.d.ts +9 -0
- package/isExternalUrl.js +21 -0
- package/isFile.d.ts +7 -0
- package/isFile.js +10 -0
- package/isFloat.d.ts +7 -0
- package/isFloat.js +10 -0
- package/isFormData.d.ts +7 -0
- package/isFormData.js +10 -0
- package/isFullArray.d.ts +7 -0
- package/isFullArray.js +10 -0
- package/isFullObject.d.ts +8 -0
- package/isFullObject.js +10 -0
- package/isFullString.d.ts +7 -0
- package/isFullString.js +10 -0
- package/isFunction.d.ts +8 -0
- package/isFunction.js +9 -0
- package/{detect.d.ts → isIE.d.ts} +3 -4
- package/isIE.js +18 -0
- package/isInt.d.ts +7 -0
- package/isInt.js +10 -0
- package/isMap.d.ts +7 -0
- package/isMap.js +10 -0
- package/isMobile.d.ts +7 -0
- package/{detect.js → isMobile.js} +4 -15
- package/isNaNValue.d.ts +7 -0
- package/isNaNValue.js +10 -0
- package/isNegativeNumber.d.ts +7 -0
- package/isNegativeNumber.js +10 -0
- package/isNull.d.ts +7 -0
- package/isNull.js +10 -0
- package/isNullOrUndefined.d.ts +7 -0
- package/isNullOrUndefined.js +10 -0
- package/isNumber.d.ts +9 -0
- package/isNumber.js +12 -0
- package/isObject.d.ts +8 -0
- package/isObject.js +10 -0
- package/isObjectLike.d.ts +10 -0
- package/isObjectLike.js +12 -0
- package/isOneOf.d.ts +9 -0
- package/isOneOf.js +10 -0
- package/isPlainObject.d.ts +8 -0
- package/isPlainObject.js +13 -0
- package/isPositiveNumber.d.ts +7 -0
- package/isPositiveNumber.js +10 -0
- package/isPrimitive.d.ts +7 -0
- package/isPrimitive.js +20 -0
- package/isPromise.d.ts +7 -0
- package/isPromise.js +10 -0
- package/isRegExp.d.ts +7 -0
- package/isRegExp.js +10 -0
- package/isServer.d.ts +6 -0
- package/isServer.js +8 -0
- package/isSet.d.ts +7 -0
- package/isSet.js +10 -0
- package/isString.d.ts +7 -0
- package/isString.js +10 -0
- package/isSymbol.d.ts +7 -0
- package/isSymbol.js +10 -0
- package/isType.d.ts +11 -0
- package/isType.js +22 -0
- package/isUndefined.d.ts +7 -0
- package/isUndefined.js +10 -0
- package/isWeakMap.d.ts +7 -0
- package/isWeakMap.js +10 -0
- package/isWeakSet.d.ts +7 -0
- package/isWeakSet.js +10 -0
- package/location.d.ts +2 -145
- package/location.js +1 -299
- package/mapListBy.d.ts +7 -0
- package/mapListBy.js +14 -0
- package/{match-sorter.d.ts → matchSorter.d.ts} +1 -0
- package/{match-sorter.js → matchSorter.js} +2 -1
- package/mergeObjects.d.ts +7 -0
- package/{objects.js → mergeObjects.js} +2 -31
- package/mergeUrlQueryParams.d.ts +9 -0
- package/mergeUrlQueryParams.js +22 -0
- package/navigateToHashParams.d.ts +9 -0
- package/navigateToHashParams.js +22 -0
- package/navigateToMergedHashParams.d.ts +8 -0
- package/navigateToMergedHashParams.js +14 -0
- package/navigateToMergedParams.d.ts +9 -0
- package/navigateToMergedParams.js +14 -0
- package/navigateToParams.d.ts +10 -0
- package/navigateToParams.js +18 -0
- package/navigateWithoutUrlParam.d.ts +8 -0
- package/navigateWithoutUrlParam.js +19 -0
- package/node/{async.js → Defer.js} +3 -9
- package/node/{emitter.js → Emitter.js} +1 -0
- package/node/accentSets.js +41 -0
- package/node/addOrReplaceAtIdx.js +23 -0
- package/node/arrayToLookup.js +17 -0
- package/node/buildUrlQueryString.js +28 -0
- package/node/changeUrlPath.js +22 -0
- package/node/chunkByChunks.js +41 -0
- package/node/chunkBySize.js +16 -0
- package/node/clamp.js +14 -0
- package/node/clsx.js +53 -0
- package/node/convertRange.js +20 -0
- package/node/cookie.js +4 -227
- package/node/decode.js +14 -0
- package/node/encode.js +14 -0
- package/node/{cast.js → ensureInt.js} +4 -6
- package/node/findDuplicatedIndexes.js +18 -0
- package/node/getKeys.js +12 -0
- package/node/getNonce.js +13 -0
- package/node/getType.js +23 -0
- package/node/getUrlHashParams.js +20 -0
- package/node/getUrlHashPathname.js +17 -0
- package/node/getUrlPathnameParts.js +24 -0
- package/node/getUrlQueryParams.js +42 -0
- package/node/index.js +108 -16
- package/node/isAnyObject.js +14 -0
- package/node/isArray.js +14 -0
- package/node/isBlob.js +14 -0
- package/node/isBoolean.js +14 -0
- package/node/{ssr.js → isBrowser.js} +6 -3
- package/node/isDate.js +14 -0
- package/node/isEmptyArray.js +14 -0
- package/node/isEmptyObject.js +14 -0
- package/node/isEmptyString.js +13 -0
- package/node/isError.js +14 -0
- package/node/isExternalUrl.js +25 -0
- package/node/isFile.js +14 -0
- package/node/isFloat.js +14 -0
- package/node/isFormData.js +14 -0
- package/node/isFullArray.js +14 -0
- package/node/isFullObject.js +14 -0
- package/node/isFullString.js +14 -0
- package/node/isFunction.js +13 -0
- package/node/isIE.js +22 -0
- package/node/isInt.js +14 -0
- package/node/isMap.js +14 -0
- package/node/{detect.js → isMobile.js} +6 -18
- package/node/isNaNValue.js +14 -0
- package/node/isNegativeNumber.js +14 -0
- package/node/isNull.js +14 -0
- package/node/isNullOrUndefined.js +13 -0
- package/node/isNumber.js +16 -0
- package/node/isObject.js +14 -0
- package/node/isObjectLike.js +16 -0
- package/node/isOneOf.js +14 -0
- package/node/isPlainObject.js +17 -0
- package/node/isPositiveNumber.js +14 -0
- package/node/isPrimitive.js +24 -0
- package/node/isPromise.js +14 -0
- package/node/isRegExp.js +14 -0
- package/node/isServer.js +11 -0
- package/node/isSet.js +14 -0
- package/node/isString.js +14 -0
- package/node/isSymbol.js +14 -0
- package/node/isType.js +26 -0
- package/node/isUndefined.js +14 -0
- package/node/isWeakMap.js +14 -0
- package/node/isWeakSet.js +14 -0
- package/node/location.js +0 -321
- package/node/mapListBy.js +18 -0
- package/node/{match-sorter.js → matchSorter.js} +3 -2
- package/node/{objects.js → mergeObjects.js} +5 -36
- package/node/mergeUrlQueryParams.js +26 -0
- package/node/navigateToHashParams.js +26 -0
- package/node/navigateToMergedHashParams.js +18 -0
- package/node/navigateToMergedParams.js +18 -0
- package/node/navigateToParams.js +22 -0
- package/node/navigateWithoutUrlParam.js +23 -0
- package/node/normaliseUrl.js +18 -0
- package/node/normaliseUrlPathname.js +18 -0
- package/node/{analytics-google.js → pageview.js} +12 -10
- package/node/parseCookie.js +52 -0
- package/node/parseURL.js +24 -0
- package/node/randomInt.js +13 -0
- package/node/{misc.js → randomKey.js} +2 -0
- package/node/readCookie.js +38 -0
- package/node/redirectTo.js +19 -0
- package/node/removeAccents.js +19 -0
- package/node/removeCookie.js +19 -0
- package/node/removeDuplicatesByKey.js +25 -0
- package/node/removeDuplicatesComparing.js +14 -0
- package/node/removeIndexesFromArray.js +18 -0
- package/node/removeTrailingSlash.js +14 -0
- package/node/{math.js → roundTo.js} +3 -32
- package/node/serializeCookie.js +108 -0
- package/node/setCookie.js +61 -0
- package/node/shuffle.js +36 -0
- package/node/slugify.js +27 -0
- package/node/swapMap.js +18 -0
- package/node/{typography.js → titleCase.js} +3 -12
- package/node/toNumber.js +12 -0
- package/node/{colors.js → toRgba.js} +4 -0
- package/node/transformToUrlPathname.js +20 -0
- package/node/truncate.js +17 -0
- package/node/uid.js +4 -13
- package/node/updateLinkParams.js +18 -0
- package/node/updateUrlQueryParams.js +22 -0
- package/node/uuid.js +17 -0
- package/node/wait.js +13 -0
- package/node/whitelistObject.js +19 -0
- package/normaliseUrl.d.ts +10 -0
- package/normaliseUrl.js +14 -0
- package/normaliseUrlPathname.d.ts +10 -0
- package/normaliseUrlPathname.js +14 -0
- package/package.json +1 -1
- package/{analytics-google.d.ts → pageview.d.ts} +3 -0
- package/{analytics-google.js → pageview.js} +12 -10
- package/parseCookie.d.ts +11 -0
- package/parseCookie.js +48 -0
- package/parseURL.d.ts +17 -0
- package/parseURL.js +20 -0
- package/randomInt.d.ts +7 -0
- package/randomInt.js +9 -0
- package/{misc.d.ts → randomKey.d.ts} +2 -0
- package/{misc.js → randomKey.js} +2 -0
- package/readCookie.d.ts +3 -0
- package/readCookie.js +34 -0
- package/redirectTo.d.ts +9 -0
- package/redirectTo.js +15 -0
- package/removeAccents.d.ts +6 -0
- package/removeAccents.js +15 -0
- package/removeCookie.d.ts +10 -0
- package/removeCookie.js +15 -0
- package/removeDuplicatesByKey.d.ts +8 -0
- package/removeDuplicatesByKey.js +21 -0
- package/removeDuplicatesComparing.d.ts +5 -0
- package/removeDuplicatesComparing.js +10 -0
- package/removeIndexesFromArray.d.ts +5 -0
- package/removeIndexesFromArray.js +14 -0
- package/removeTrailingSlash.d.ts +7 -0
- package/removeTrailingSlash.js +10 -0
- package/roundTo.d.ts +8 -0
- package/{math.js → roundTo.js} +2 -28
- package/serializeCookie.d.ts +27 -0
- package/serializeCookie.js +104 -0
- package/setCookie.d.ts +10 -0
- package/setCookie.js +57 -0
- package/shuffle.d.ts +16 -0
- package/shuffle.js +32 -0
- package/{text.d.ts → slugify.d.ts} +2 -5
- package/slugify.js +23 -0
- package/swapMap.d.ts +7 -0
- package/swapMap.js +14 -0
- package/{typography.d.ts → titleCase.d.ts} +2 -4
- package/{typography.js → titleCase.js} +2 -10
- package/toNumber.d.ts +5 -0
- package/toNumber.js +8 -0
- package/{colors.d.ts → toRgba.d.ts} +4 -0
- package/{colors.js → toRgba.js} +4 -0
- package/transformToUrlPathname.d.ts +11 -0
- package/transformToUrlPathname.js +16 -0
- package/truncate.d.ts +7 -0
- package/truncate.js +13 -0
- package/uid.d.ts +3 -6
- package/uid.js +3 -11
- package/updateLinkParams.d.ts +10 -0
- package/updateLinkParams.js +14 -0
- package/updateUrlQueryParams.d.ts +9 -0
- package/updateUrlQueryParams.js +18 -0
- package/uuid.d.ts +8 -0
- package/uuid.js +13 -0
- package/wait.d.ts +7 -0
- package/wait.js +9 -0
- package/whitelistObject.d.ts +8 -0
- package/whitelistObject.js +15 -0
- package/arrays.d.ts +0 -41
- package/arrays.js +0 -153
- package/is.d.ts +0 -288
- package/is.js +0 -376
- package/math.d.ts +0 -28
- package/node/arrays.js +0 -166
- package/node/is.js +0 -417
- package/node/security.js +0 -29
- package/node/text.js +0 -70
- package/objects.d.ts +0 -22
- package/security.d.ts +0 -12
- package/security.js +0 -23
- package/ssr.d.ts +0 -2
- package/text.js +0 -65
package/location.d.ts
CHANGED
|
@@ -1,147 +1,4 @@
|
|
|
1
|
-
export declare type AnyQueryParams = undefined | null | Record<string | number, unknown>;
|
|
2
|
-
/**
|
|
3
|
-
* Solution without DOM or specific env native methods
|
|
4
|
-
*
|
|
5
|
-
* @see https://stackoverflow.com/a/21553982/1938970
|
|
6
|
-
*/
|
|
7
|
-
export declare function parseURL(url: string): {
|
|
8
|
-
href: string;
|
|
9
|
-
protocol: string;
|
|
10
|
-
host: string;
|
|
11
|
-
hostname: string;
|
|
12
|
-
port: string;
|
|
13
|
-
pathname: string;
|
|
14
|
-
search: string;
|
|
15
|
-
hash: string;
|
|
16
|
-
} | null;
|
|
17
|
-
/**
|
|
18
|
-
* Strips out the trailing slash
|
|
19
|
-
*/
|
|
20
|
-
export declare function removeTralingSlash(urlLike?: string): string;
|
|
21
|
-
/**
|
|
22
|
-
* Normalise URL (absolute URL)
|
|
23
|
-
*
|
|
24
|
-
* - replaces too many consecutive slashes (except `http{s}://`)
|
|
25
|
-
* - removes the trailing slash
|
|
26
|
-
*/
|
|
27
|
-
export declare function normaliseUrl(absoluteUrl?: string): string;
|
|
28
|
-
/**
|
|
29
|
-
* Normalise URL pathname (relative URL)
|
|
30
|
-
*
|
|
31
|
-
* - replaces too many consecutive slashes
|
|
32
|
-
* - removes the trailing slash
|
|
33
|
-
*/
|
|
34
|
-
export declare function normaliseUrlPathname(pathname?: string): string;
|
|
35
|
-
/**
|
|
36
|
-
* Transform string in a URL pathname (relative URL)
|
|
37
|
-
*
|
|
38
|
-
* - adds an initial slash
|
|
39
|
-
* - encode the string
|
|
40
|
-
* - replaces whitespaces with dashes
|
|
41
|
-
*/
|
|
42
|
-
export declare function transformToUrlPathname(toPathname?: string): string;
|
|
43
|
-
/**
|
|
44
|
-
* Get parsed query parameters as object dictionary (from URL or given query string)
|
|
45
|
-
*
|
|
46
|
-
* @param url A URL which contains a `?`, e.g. `?myparam=x` or `https://a.com?myparams=x`.
|
|
47
|
-
* If not provided it defaults reading the current URL query string with
|
|
48
|
-
* `location.search`. Through this argument you can use this
|
|
49
|
-
* same function to parse, for instance, the query params of
|
|
50
|
-
* the `href` of a `<a href="...">` HTML tag.
|
|
51
|
-
*
|
|
52
|
-
*/
|
|
53
|
-
export declare function getUrlQueryParams<T extends NonNullable<AnyQueryParams>>(url?: string): T;
|
|
54
|
-
/**
|
|
55
|
-
* Get pathname parts
|
|
56
|
-
*
|
|
57
|
-
* First clean the pathname from the first slash if any then split the pathname
|
|
58
|
-
* in parts,
|
|
59
|
-
* Given a pathname like: `"/en/{prefix}/{collection}/{slug}"` we obtain
|
|
60
|
-
* `[locale, prefix, collection, slug]`
|
|
61
|
-
*/
|
|
62
|
-
export declare function getUrlPathnameParts(pathname?: string): string[];
|
|
63
|
-
/**
|
|
64
|
-
* Get clean query string for URL
|
|
65
|
-
*
|
|
66
|
-
* It returns the query string **with** the initial `?`
|
|
67
|
-
*
|
|
68
|
-
* TODO: at some point replace with `URLSearchParams`, @see [caniuse](https://caniuse.com/?search=URLSearchParams)
|
|
69
|
-
*/
|
|
70
|
-
export declare function buildUrlQueryString(params?: AnyQueryParams): string;
|
|
71
|
-
/**
|
|
72
|
-
* Change URL path, ensures initial and ending slashes and normalise eventual
|
|
73
|
-
* consecutive slashes, it uses `history`.
|
|
74
|
-
*
|
|
75
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
76
|
-
* @returns {string} The new cleaned pathname
|
|
77
|
-
*/
|
|
78
|
-
export declare function changeUrlPath(pathname: string, state?: object, replace?: boolean): string;
|
|
79
|
-
/**
|
|
80
|
-
* Change current URL query parameters, it uses `history`.
|
|
81
|
-
*
|
|
82
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
83
|
-
* @returns The query string with initial `?`
|
|
84
|
-
*/
|
|
85
|
-
export declare function navigateToParams(params?: string | AnyQueryParams, replace?: boolean): string;
|
|
86
1
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
2
|
+
* @category location
|
|
90
3
|
*/
|
|
91
|
-
export declare
|
|
92
|
-
/**
|
|
93
|
-
* Remove URL query parameter, it uses `history`
|
|
94
|
-
*
|
|
95
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
96
|
-
*/
|
|
97
|
-
export declare function navigateWithoutUrlParam(paramName?: string, replace?: boolean): string;
|
|
98
|
-
/**
|
|
99
|
-
* Merge query parameters objects, it *mutates* the first given object argument
|
|
100
|
-
*
|
|
101
|
-
* @pure
|
|
102
|
-
*/
|
|
103
|
-
export declare function mergeUrlQueryParams<T extends AnyQueryParams>(oldParams?: NonNullable<AnyQueryParams>, newParams?: NonNullable<AnyQueryParams>): T;
|
|
104
|
-
/**
|
|
105
|
-
* Update a URL string query parameters merging the given new query parameters
|
|
106
|
-
*
|
|
107
|
-
* @pure
|
|
108
|
-
*/
|
|
109
|
-
export declare function updateUrlQueryParams(url: string, newParams?: NonNullable<AnyQueryParams>): string;
|
|
110
|
-
/**
|
|
111
|
-
* Update link `<a href="">` merging the given new query parameters.
|
|
112
|
-
* it returns the newly created `href` URL value
|
|
113
|
-
*
|
|
114
|
-
* @pure
|
|
115
|
-
*/
|
|
116
|
-
export declare function updateLinkParams($anchor: HTMLAnchorElement, newParams: NonNullable<AnyQueryParams>): string;
|
|
117
|
-
/**
|
|
118
|
-
* Redirect to url with params {optionally}, removes eventual trailing question
|
|
119
|
-
* marks from the given URL, it uses `location`
|
|
120
|
-
*/
|
|
121
|
-
export declare function redirectTo(url: string, params?: AnyQueryParams): void;
|
|
122
|
-
/**
|
|
123
|
-
* Is external url compared to the given current URL (if not provided it falls
|
|
124
|
-
* back to `location.href`)
|
|
125
|
-
*
|
|
126
|
-
*/
|
|
127
|
-
export declare function isExternalUrl(url: string, currentUrl?: string): boolean;
|
|
128
|
-
/**
|
|
129
|
-
* It updates the `location.hash` with the given query params, it uses `location.hash`
|
|
130
|
-
* if a second argument `hash` is not provded
|
|
131
|
-
*/
|
|
132
|
-
export declare function navigateToHashParams(params?: string | AnyQueryParams, hash?: string): string;
|
|
133
|
-
/**
|
|
134
|
-
* It updates the "query params" within the `location.hash`, it uses `location`
|
|
135
|
-
*/
|
|
136
|
-
export declare function navigateToMergedHashParams(params?: NonNullable<AnyQueryParams>, hash?: string): string;
|
|
137
|
-
/**
|
|
138
|
-
* It returns the "query params" as an object extracting it from the given `hash`
|
|
139
|
-
*string or, if not provided, failling back reading the `location.hash`
|
|
140
|
-
*/
|
|
141
|
-
export declare function getUrlHashParams<T extends NonNullable<AnyQueryParams>>(hash?: string): T;
|
|
142
|
-
/**
|
|
143
|
-
* It returns the "pathname" cleaned up from the `#` and the initial slashes
|
|
144
|
-
* extracting it from the given `hash` string or, if not provided, failling
|
|
145
|
-
* back reading the `location.hash`
|
|
146
|
-
*/
|
|
147
|
-
export declare function getUrlHashPathname(hash?: string): string;
|
|
4
|
+
export declare type AnyQueryParams = undefined | null | Record<string | number, unknown>;
|
package/location.js
CHANGED
|
@@ -1,299 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { isString, isNull, isUndefined } from "./is";
|
|
3
|
-
/**
|
|
4
|
-
* Solution without DOM or specific env native methods
|
|
5
|
-
*
|
|
6
|
-
* @see https://stackoverflow.com/a/21553982/1938970
|
|
7
|
-
*/
|
|
8
|
-
export function parseURL(url) {
|
|
9
|
-
var match = url.match(/^(https?:)\/\/(([^:/?#]*)(?::([0-9]+))?)([/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);
|
|
10
|
-
return (match && {
|
|
11
|
-
href: url,
|
|
12
|
-
protocol: match[1],
|
|
13
|
-
host: match[2],
|
|
14
|
-
hostname: match[3],
|
|
15
|
-
port: match[4],
|
|
16
|
-
pathname: match[5],
|
|
17
|
-
search: match[6],
|
|
18
|
-
hash: match[7],
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Strips out the trailing slash
|
|
23
|
-
*/
|
|
24
|
-
export function removeTralingSlash(urlLike) {
|
|
25
|
-
if (urlLike === void 0) { urlLike = ""; }
|
|
26
|
-
return urlLike.replace(/\/*$/, "");
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Normalise URL (absolute URL)
|
|
30
|
-
*
|
|
31
|
-
* - replaces too many consecutive slashes (except `http{s}://`)
|
|
32
|
-
* - removes the trailing slash
|
|
33
|
-
*/
|
|
34
|
-
export function normaliseUrl(absoluteUrl) {
|
|
35
|
-
if (absoluteUrl === void 0) { absoluteUrl = ""; }
|
|
36
|
-
return removeTralingSlash(absoluteUrl.replace(/([^:]\/)\/+/g, "$1"));
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Normalise URL pathname (relative URL)
|
|
40
|
-
*
|
|
41
|
-
* - replaces too many consecutive slashes
|
|
42
|
-
* - removes the trailing slash
|
|
43
|
-
*/
|
|
44
|
-
export function normaliseUrlPathname(pathname) {
|
|
45
|
-
if (pathname === void 0) { pathname = ""; }
|
|
46
|
-
return removeTralingSlash(pathname.replace(/\/+/g, "/"));
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Transform string in a URL pathname (relative URL)
|
|
50
|
-
*
|
|
51
|
-
* - adds an initial slash
|
|
52
|
-
* - encode the string
|
|
53
|
-
* - replaces whitespaces with dashes
|
|
54
|
-
*/
|
|
55
|
-
export function transformToUrlPathname(toPathname) {
|
|
56
|
-
return isString(toPathname)
|
|
57
|
-
? "/".concat(encodeURIComponent(toPathname.replace(/\s/g, "-").toLowerCase()))
|
|
58
|
-
: "";
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get parsed query parameters as object dictionary (from URL or given query string)
|
|
62
|
-
*
|
|
63
|
-
* @param url A URL which contains a `?`, e.g. `?myparam=x` or `https://a.com?myparams=x`.
|
|
64
|
-
* If not provided it defaults reading the current URL query string with
|
|
65
|
-
* `location.search`. Through this argument you can use this
|
|
66
|
-
* same function to parse, for instance, the query params of
|
|
67
|
-
* the `href` of a `<a href="...">` HTML tag.
|
|
68
|
-
*
|
|
69
|
-
*/
|
|
70
|
-
export function getUrlQueryParams(url) {
|
|
71
|
-
var _a;
|
|
72
|
-
var params = {};
|
|
73
|
-
var search = url
|
|
74
|
-
? (_a = url.split("?")) === null || _a === void 0 ? void 0 : _a[1]
|
|
75
|
-
: isBrowser
|
|
76
|
-
? location.search.substring(1)
|
|
77
|
-
: "";
|
|
78
|
-
if (!search) {
|
|
79
|
-
return {};
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
// @see https://stackoverflow.com/a/8649003/1938970
|
|
83
|
-
var paramsAsObj = "{\"".concat(search
|
|
84
|
-
.replace(/&/g, '","')
|
|
85
|
-
.replace(/=/g, '":"'), "\"}");
|
|
86
|
-
params = JSON.parse(paramsAsObj, function (key, value) {
|
|
87
|
-
return key === "" ? value : decodeURIComponent(value);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
// do nothing or warn on process.env["NODE_ENV"] !== "production"
|
|
92
|
-
}
|
|
93
|
-
return params;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Get pathname parts
|
|
97
|
-
*
|
|
98
|
-
* First clean the pathname from the first slash if any then split the pathname
|
|
99
|
-
* in parts,
|
|
100
|
-
* Given a pathname like: `"/en/{prefix}/{collection}/{slug}"` we obtain
|
|
101
|
-
* `[locale, prefix, collection, slug]`
|
|
102
|
-
*/
|
|
103
|
-
export function getUrlPathnameParts(pathname) {
|
|
104
|
-
if (pathname === void 0) { pathname = ""; }
|
|
105
|
-
pathname = pathname || isBrowser ? location.pathname : "";
|
|
106
|
-
return pathname
|
|
107
|
-
.replace(/^\//, "")
|
|
108
|
-
.split("/")
|
|
109
|
-
.filter(function (part) { return part; });
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Get clean query string for URL
|
|
113
|
-
*
|
|
114
|
-
* It returns the query string **with** the initial `?`
|
|
115
|
-
*
|
|
116
|
-
* TODO: at some point replace with `URLSearchParams`, @see [caniuse](https://caniuse.com/?search=URLSearchParams)
|
|
117
|
-
*/
|
|
118
|
-
export function buildUrlQueryString(params) {
|
|
119
|
-
if (params === void 0) { params = {}; }
|
|
120
|
-
var output = "";
|
|
121
|
-
for (var key in params) {
|
|
122
|
-
var value = params[key];
|
|
123
|
-
if (!isNull(value) && !isUndefined(value)) {
|
|
124
|
-
output += "".concat(key, "=").concat(encodeURIComponent(value + ""), "&");
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// removes the last &
|
|
128
|
-
return output ? "?".concat(output.replace(/&+$/, "")) : "";
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Change URL path, ensures initial and ending slashes and normalise eventual
|
|
132
|
-
* consecutive slashes, it uses `history`.
|
|
133
|
-
*
|
|
134
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
135
|
-
* @returns {string} The new cleaned pathname
|
|
136
|
-
*/
|
|
137
|
-
export function changeUrlPath(pathname, state, replace) {
|
|
138
|
-
var path = normaliseUrlPathname("/".concat(pathname, "/"));
|
|
139
|
-
if (isBrowser) {
|
|
140
|
-
history[replace ? "replaceState" : "pushState"](state, "", path);
|
|
141
|
-
}
|
|
142
|
-
return path;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Change current URL query parameters, it uses `history`.
|
|
146
|
-
*
|
|
147
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
148
|
-
* @returns The query string with initial `?`
|
|
149
|
-
*/
|
|
150
|
-
export function navigateToParams(params, replace) {
|
|
151
|
-
if (params === void 0) { params = {}; }
|
|
152
|
-
var queryString = typeof params === "string" ? params : buildUrlQueryString(params);
|
|
153
|
-
if (isBrowser) {
|
|
154
|
-
history[replace ? "replaceState" : "pushState"](null, "", location.pathname + queryString);
|
|
155
|
-
}
|
|
156
|
-
return queryString;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Merge current URL query parameters with the given ones, it uses `history`.
|
|
160
|
-
*
|
|
161
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
162
|
-
*/
|
|
163
|
-
export function navigateToMergedParams(params, replace) {
|
|
164
|
-
if (params === void 0) { params = {}; }
|
|
165
|
-
return navigateToParams(mergeUrlQueryParams(getUrlQueryParams(), params), replace);
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Remove URL query parameter, it uses `history`
|
|
169
|
-
*
|
|
170
|
-
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
171
|
-
*/
|
|
172
|
-
export function navigateWithoutUrlParam(paramName, replace) {
|
|
173
|
-
var params = {};
|
|
174
|
-
var currentParams = getUrlQueryParams();
|
|
175
|
-
for (var key in currentParams) {
|
|
176
|
-
if (key !== paramName) {
|
|
177
|
-
params[key] = currentParams[key];
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
return navigateToParams(params, replace);
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Merge query parameters objects, it *mutates* the first given object argument
|
|
184
|
-
*
|
|
185
|
-
* @pure
|
|
186
|
-
*/
|
|
187
|
-
export function mergeUrlQueryParams(oldParams, newParams) {
|
|
188
|
-
if (oldParams === void 0) { oldParams = {}; }
|
|
189
|
-
if (newParams === void 0) { newParams = {}; }
|
|
190
|
-
for (var key in newParams) {
|
|
191
|
-
var value = newParams[key];
|
|
192
|
-
if (oldParams[key] && isNull(value)) {
|
|
193
|
-
delete oldParams[key];
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
oldParams[key] = value;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return oldParams;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Update a URL string query parameters merging the given new query parameters
|
|
203
|
-
*
|
|
204
|
-
* @pure
|
|
205
|
-
*/
|
|
206
|
-
export function updateUrlQueryParams(url, newParams) {
|
|
207
|
-
if (newParams === void 0) { newParams = {}; }
|
|
208
|
-
var parts = url.split("?");
|
|
209
|
-
var allParams = parts[1]
|
|
210
|
-
? mergeUrlQueryParams(getUrlQueryParams(url), newParams)
|
|
211
|
-
: newParams;
|
|
212
|
-
return parts[0] + buildUrlQueryString(allParams);
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Update link `<a href="">` merging the given new query parameters.
|
|
216
|
-
* it returns the newly created `href` URL value
|
|
217
|
-
*
|
|
218
|
-
* @pure
|
|
219
|
-
*/
|
|
220
|
-
export function updateLinkParams($anchor, newParams) {
|
|
221
|
-
var href = updateUrlQueryParams($anchor.href, newParams);
|
|
222
|
-
$anchor.href = href;
|
|
223
|
-
return href;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Redirect to url with params {optionally}, removes eventual trailing question
|
|
227
|
-
* marks from the given URL, it uses `location`
|
|
228
|
-
*/
|
|
229
|
-
export function redirectTo(url, params) {
|
|
230
|
-
if (isBrowser) {
|
|
231
|
-
var queryString = buildUrlQueryString(params);
|
|
232
|
-
location.href = url.replace(/\?+$/g, "") + queryString;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Is external url compared to the given current URL (if not provided it falls
|
|
237
|
-
* back to `location.href`)
|
|
238
|
-
*
|
|
239
|
-
*/
|
|
240
|
-
export function isExternalUrl(url, currentUrl) {
|
|
241
|
-
var _a;
|
|
242
|
-
var reg = /https?:\/\/((?:[\w\d-]+\.)+[\w\d]{2,})/i;
|
|
243
|
-
var urlMatches = reg.exec(url);
|
|
244
|
-
// if no matches are found it means we either have an invalid URL, a relative
|
|
245
|
-
// URL or a hash link, and those are not considered externals
|
|
246
|
-
if (!urlMatches) {
|
|
247
|
-
return false;
|
|
248
|
-
}
|
|
249
|
-
currentUrl = currentUrl || isBrowser ? location.href : "";
|
|
250
|
-
return currentUrl ? ((_a = reg.exec(currentUrl)) === null || _a === void 0 ? void 0 : _a[1]) !== urlMatches[1] : true;
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* It updates the `location.hash` with the given query params, it uses `location.hash`
|
|
254
|
-
* if a second argument `hash` is not provded
|
|
255
|
-
*/
|
|
256
|
-
export function navigateToHashParams(params, hash) {
|
|
257
|
-
if (params === void 0) { params = {}; }
|
|
258
|
-
if (hash === void 0) { hash = ""; }
|
|
259
|
-
var useLocation = !hash;
|
|
260
|
-
hash = hash || location.hash;
|
|
261
|
-
var hashQueryLess = getUrlHashPathname(hash);
|
|
262
|
-
var queryString = typeof params === "string" ? params : buildUrlQueryString(params);
|
|
263
|
-
var newHash = "#/" + hashQueryLess + queryString;
|
|
264
|
-
if (useLocation) {
|
|
265
|
-
location.hash = newHash;
|
|
266
|
-
}
|
|
267
|
-
return newHash;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* It updates the "query params" within the `location.hash`, it uses `location`
|
|
271
|
-
*/
|
|
272
|
-
export function navigateToMergedHashParams(params, hash) {
|
|
273
|
-
if (params === void 0) { params = {}; }
|
|
274
|
-
if (hash === void 0) { hash = ""; }
|
|
275
|
-
return navigateToHashParams(mergeUrlQueryParams(getUrlHashParams(hash), params), hash);
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* It returns the "query params" as an object extracting it from the given `hash`
|
|
279
|
-
*string or, if not provided, failling back reading the `location.hash`
|
|
280
|
-
*/
|
|
281
|
-
export function getUrlHashParams(hash) {
|
|
282
|
-
if (hash === void 0) { hash = ""; }
|
|
283
|
-
hash = hash || location.hash;
|
|
284
|
-
var hashParts = hash.split("?");
|
|
285
|
-
if (hashParts.length >= 1) {
|
|
286
|
-
return Object.fromEntries(new URLSearchParams(hashParts[1]));
|
|
287
|
-
}
|
|
288
|
-
return {};
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* It returns the "pathname" cleaned up from the `#` and the initial slashes
|
|
292
|
-
* extracting it from the given `hash` string or, if not provided, failling
|
|
293
|
-
* back reading the `location.hash`
|
|
294
|
-
*/
|
|
295
|
-
export function getUrlHashPathname(hash) {
|
|
296
|
-
if (hash === void 0) { hash = ""; }
|
|
297
|
-
hash = hash || location.hash;
|
|
298
|
-
return hash.split("?")[0].replace(/^#\//, "");
|
|
299
|
-
}
|
|
1
|
+
export {};
|
package/mapListBy.d.ts
ADDED
package/mapListBy.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps an array of objects into a map keyed with the given key
|
|
3
|
+
*
|
|
4
|
+
* @category array
|
|
5
|
+
*/
|
|
6
|
+
export function mapListBy(array, key) {
|
|
7
|
+
if (array === void 0) { array = []; }
|
|
8
|
+
if (key === void 0) { key = ""; }
|
|
9
|
+
return array.reduce(function (obj, item) {
|
|
10
|
+
obj[item[key]] = item;
|
|
11
|
+
return obj;
|
|
12
|
+
}, {});
|
|
13
|
+
}
|
|
14
|
+
export default mapListBy;
|
|
@@ -58,3 +58,4 @@ declare const defaultBaseSortFn: BaseSorter<unknown>;
|
|
|
58
58
|
declare function matchSorter<ItemType = string>(items: ReadonlyArray<ItemType>, value: string, options?: MatchSorterOptions<ItemType>): Array<ItemType>;
|
|
59
59
|
export { matchSorter, defaultBaseSortFn };
|
|
60
60
|
export type { MatchSorterOptions, KeyAttributesOptions, KeyOption, KeyAttributes, RankingInfo, ValueGetterKey, };
|
|
61
|
+
export default matchSorter;
|
|
@@ -15,7 +15,7 @@ import { __assign } from "tslib";
|
|
|
15
15
|
* @copyright (c) 2020 Kent C. Dodds
|
|
16
16
|
* @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
|
|
17
17
|
*/
|
|
18
|
-
import
|
|
18
|
+
import removeAccents from "./removeAccents";
|
|
19
19
|
var RANKING_CASE_SENSITIVE_EQUAL = 7;
|
|
20
20
|
var RANKING_EQUAL = 6;
|
|
21
21
|
var RANKING_STARTS_WITH = 5;
|
|
@@ -367,3 +367,4 @@ function getKeyAttributes(key) {
|
|
|
367
367
|
return __assign(__assign({}, defaultKeyAttributes), key);
|
|
368
368
|
}
|
|
369
369
|
export { matchSorter, defaultBaseSortFn };
|
|
370
|
+
export default matchSorter;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { __spreadArray } from "tslib";
|
|
2
|
-
import { isObject } from "./
|
|
3
|
-
/**
|
|
4
|
-
* Type safe replacement for `Object.keys(myObject)` to iterate over a record
|
|
5
|
-
* without loosing the key's types in simple `string`s.
|
|
6
|
-
*
|
|
7
|
-
* @see https://stackoverflow.com/a/59459000/1938970
|
|
8
|
-
*/
|
|
9
|
-
export var getKeys = Object.keys;
|
|
2
|
+
import { isObject } from "./isObject";
|
|
10
3
|
/**
|
|
11
4
|
* Merge two or more objects together. It mutates the target object.
|
|
12
5
|
*
|
|
6
|
+
* @category objects
|
|
13
7
|
* @see https://stackoverflow.com/a/46973278/1938970
|
|
14
8
|
*/
|
|
15
9
|
export var mergeObjects = function (target) {
|
|
@@ -41,26 +35,3 @@ export var mergeObjects = function (target) {
|
|
|
41
35
|
}
|
|
42
36
|
return mergeObjects.apply(void 0, __spreadArray([target], sources, false));
|
|
43
37
|
};
|
|
44
|
-
/**
|
|
45
|
-
* Swap object map key/value
|
|
46
|
-
*/
|
|
47
|
-
export function swapMap(map) {
|
|
48
|
-
if (map === void 0) { map = {}; }
|
|
49
|
-
var output = {};
|
|
50
|
-
for (var key in map) {
|
|
51
|
-
output[map[key]] = key;
|
|
52
|
-
}
|
|
53
|
-
return output;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Whitelist an object properties by selecting only the given keys, it returns a
|
|
57
|
-
* new object.
|
|
58
|
-
*/
|
|
59
|
-
export function whitelistObject(object, keys) {
|
|
60
|
-
var output = {};
|
|
61
|
-
var len = keys.length;
|
|
62
|
-
while (len--) {
|
|
63
|
-
output[keys[len]] = object[keys[len]];
|
|
64
|
-
}
|
|
65
|
-
return output;
|
|
66
|
-
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AnyQueryParams } from "./location";
|
|
2
|
+
/**
|
|
3
|
+
* Merge query parameters objects, it *mutates* the first given object argument
|
|
4
|
+
*
|
|
5
|
+
* @category location
|
|
6
|
+
* @pure
|
|
7
|
+
*/
|
|
8
|
+
export declare function mergeUrlQueryParams<T extends AnyQueryParams>(oldParams?: NonNullable<AnyQueryParams>, newParams?: NonNullable<AnyQueryParams>): T;
|
|
9
|
+
export default mergeUrlQueryParams;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import isNull from "./isNull";
|
|
2
|
+
/**
|
|
3
|
+
* Merge query parameters objects, it *mutates* the first given object argument
|
|
4
|
+
*
|
|
5
|
+
* @category location
|
|
6
|
+
* @pure
|
|
7
|
+
*/
|
|
8
|
+
export function mergeUrlQueryParams(oldParams, newParams) {
|
|
9
|
+
if (oldParams === void 0) { oldParams = {}; }
|
|
10
|
+
if (newParams === void 0) { newParams = {}; }
|
|
11
|
+
for (var key in newParams) {
|
|
12
|
+
var value = newParams[key];
|
|
13
|
+
if (oldParams[key] && isNull(value)) {
|
|
14
|
+
delete oldParams[key];
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
oldParams[key] = value;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return oldParams;
|
|
21
|
+
}
|
|
22
|
+
export default mergeUrlQueryParams;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AnyQueryParams } from "./location";
|
|
2
|
+
/**
|
|
3
|
+
* It updates the `location.hash` with the given query params, it uses `location.hash`
|
|
4
|
+
* if a second argument `hash` is not provded
|
|
5
|
+
*
|
|
6
|
+
* @category location
|
|
7
|
+
*/
|
|
8
|
+
export declare function navigateToHashParams(params?: string | AnyQueryParams, hash?: string): string;
|
|
9
|
+
export default navigateToHashParams;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import buildUrlQueryString from "./buildUrlQueryString";
|
|
2
|
+
import getUrlHashPathname from "./getUrlHashPathname";
|
|
3
|
+
/**
|
|
4
|
+
* It updates the `location.hash` with the given query params, it uses `location.hash`
|
|
5
|
+
* if a second argument `hash` is not provded
|
|
6
|
+
*
|
|
7
|
+
* @category location
|
|
8
|
+
*/
|
|
9
|
+
export function navigateToHashParams(params, hash) {
|
|
10
|
+
if (params === void 0) { params = {}; }
|
|
11
|
+
if (hash === void 0) { hash = ""; }
|
|
12
|
+
var useLocation = !hash;
|
|
13
|
+
hash = hash || location.hash;
|
|
14
|
+
var hashQueryLess = getUrlHashPathname(hash);
|
|
15
|
+
var queryString = typeof params === "string" ? params : buildUrlQueryString(params);
|
|
16
|
+
var newHash = "#/" + hashQueryLess + queryString;
|
|
17
|
+
if (useLocation) {
|
|
18
|
+
location.hash = newHash;
|
|
19
|
+
}
|
|
20
|
+
return newHash;
|
|
21
|
+
}
|
|
22
|
+
export default navigateToHashParams;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type AnyQueryParams } from "./location";
|
|
2
|
+
/**
|
|
3
|
+
* It updates the "query params" within the `location.hash`, it uses `location`
|
|
4
|
+
*
|
|
5
|
+
* @category location
|
|
6
|
+
*/
|
|
7
|
+
export declare function navigateToMergedHashParams(params?: NonNullable<AnyQueryParams>, hash?: string): string;
|
|
8
|
+
export default navigateToMergedHashParams;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import getUrlHashParams from "./getUrlHashParams";
|
|
2
|
+
import mergeUrlQueryParams from "./mergeUrlQueryParams";
|
|
3
|
+
import navigateToHashParams from "./navigateToHashParams";
|
|
4
|
+
/**
|
|
5
|
+
* It updates the "query params" within the `location.hash`, it uses `location`
|
|
6
|
+
*
|
|
7
|
+
* @category location
|
|
8
|
+
*/
|
|
9
|
+
export function navigateToMergedHashParams(params, hash) {
|
|
10
|
+
if (params === void 0) { params = {}; }
|
|
11
|
+
if (hash === void 0) { hash = ""; }
|
|
12
|
+
return navigateToHashParams(mergeUrlQueryParams(getUrlHashParams(hash), params), hash);
|
|
13
|
+
}
|
|
14
|
+
export default navigateToMergedHashParams;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AnyQueryParams } from "./location";
|
|
2
|
+
/**
|
|
3
|
+
* Merge current URL query parameters with the given ones, it uses `history`.
|
|
4
|
+
*
|
|
5
|
+
* @category location
|
|
6
|
+
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function navigateToMergedParams(params?: NonNullable<AnyQueryParams>, replace?: boolean): string;
|
|
9
|
+
export default navigateToMergedParams;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import getUrlQueryParams from "./getUrlQueryParams";
|
|
2
|
+
import mergeUrlQueryParams from "./mergeUrlQueryParams";
|
|
3
|
+
import navigateToParams from "./navigateToParams";
|
|
4
|
+
/**
|
|
5
|
+
* Merge current URL query parameters with the given ones, it uses `history`.
|
|
6
|
+
*
|
|
7
|
+
* @category location
|
|
8
|
+
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
9
|
+
*/
|
|
10
|
+
export function navigateToMergedParams(params, replace) {
|
|
11
|
+
if (params === void 0) { params = {}; }
|
|
12
|
+
return navigateToParams(mergeUrlQueryParams(getUrlQueryParams(), params), replace);
|
|
13
|
+
}
|
|
14
|
+
export default navigateToMergedParams;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type AnyQueryParams } from "./location";
|
|
2
|
+
/**
|
|
3
|
+
* Change current URL query parameters, it uses `history`.
|
|
4
|
+
*
|
|
5
|
+
* @category location
|
|
6
|
+
* @param replace Replace URL instead of pushing it in the history stack. By default it pushes it.
|
|
7
|
+
* @returns The query string with initial `?`
|
|
8
|
+
*/
|
|
9
|
+
export declare function navigateToParams(params?: string | AnyQueryParams, replace?: boolean): string;
|
|
10
|
+
export default navigateToParams;
|