@jeniex/utils 1.0.21 → 1.0.22
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/browser/index.cjs +21 -0
- package/browser/index.d.ts +6 -1
- package/browser/index.js +21 -1
- package/package.json +1 -1
package/browser/index.cjs
CHANGED
|
@@ -286,6 +286,26 @@ function setSearchParam(key, value, fullURL) {
|
|
|
286
286
|
}
|
|
287
287
|
return updatedURL.join('');
|
|
288
288
|
}
|
|
289
|
+
/**
|
|
290
|
+
* @param keys The names of the param in the search query.
|
|
291
|
+
* @param fullURL If provided, it will be our target, otherwise it is the current location.
|
|
292
|
+
*/
|
|
293
|
+
function removeSearchParams(keys, fullURL) {
|
|
294
|
+
const updatedURL = [];
|
|
295
|
+
const { origin, pathname, search, hash } = new URL(fullURL ?? window.location.href);
|
|
296
|
+
const searchParams = new URLSearchParams(search);
|
|
297
|
+
for (const key of keys) {
|
|
298
|
+
searchParams.delete(key);
|
|
299
|
+
}
|
|
300
|
+
updatedURL.push(origin, pathname);
|
|
301
|
+
if (searchParams.toString() !== '') {
|
|
302
|
+
updatedURL.push('?', searchParams.toString());
|
|
303
|
+
}
|
|
304
|
+
if (hash !== '') {
|
|
305
|
+
updatedURL.push(hash);
|
|
306
|
+
}
|
|
307
|
+
return updatedURL.join('');
|
|
308
|
+
}
|
|
289
309
|
|
|
290
310
|
function addStyle(css, parent = document.documentElement) {
|
|
291
311
|
const style = document.createElement('style');
|
|
@@ -446,6 +466,7 @@ exports.padZeros = padZeros;
|
|
|
446
466
|
exports.pageLoad = pageLoad;
|
|
447
467
|
exports.prompt = prompt;
|
|
448
468
|
exports.remove = remove;
|
|
469
|
+
exports.removeSearchParams = removeSearchParams;
|
|
449
470
|
exports.scriptName = scriptName;
|
|
450
471
|
exports.setSearchParam = setSearchParam;
|
|
451
472
|
exports.sleep = sleep;
|
package/browser/index.d.ts
CHANGED
|
@@ -100,6 +100,11 @@ declare function getSearchParam(key: string, fullURL?: string): string | undefin
|
|
|
100
100
|
* @param fullURL If provided, it will be our target, otherwise it is the current location.
|
|
101
101
|
*/
|
|
102
102
|
declare function setSearchParam(key: string, value: string, fullURL?: string): string;
|
|
103
|
+
/**
|
|
104
|
+
* @param keys The names of the param in the search query.
|
|
105
|
+
* @param fullURL If provided, it will be our target, otherwise it is the current location.
|
|
106
|
+
*/
|
|
107
|
+
declare function removeSearchParams(keys: string[], fullURL?: string): string;
|
|
103
108
|
|
|
104
109
|
declare const scriptName: string;
|
|
105
110
|
/** The identifier of the script to be used in logging. */
|
|
@@ -146,4 +151,4 @@ type Options = Record<string, FlagValue>;
|
|
|
146
151
|
|
|
147
152
|
declare function getOptions(flags: Flag[]): Promise<Options>;
|
|
148
153
|
|
|
149
|
-
export { $, $$, Flag, Fn, Nullable, Prettify, addStyle, alert, asserted, capitalize, confirm, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, logId, noop, padZeros, pageLoad, prompt, remove, scriptName, setSearchParam, sleep, tabURL, toString };
|
|
154
|
+
export { $, $$, Flag, Fn, Nullable, Prettify, addStyle, alert, asserted, capitalize, confirm, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, logId, noop, padZeros, pageLoad, prompt, remove, removeSearchParams, scriptName, setSearchParam, sleep, tabURL, toString };
|
package/browser/index.js
CHANGED
|
@@ -284,6 +284,26 @@ function setSearchParam(key, value, fullURL) {
|
|
|
284
284
|
}
|
|
285
285
|
return updatedURL.join('');
|
|
286
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* @param keys The names of the param in the search query.
|
|
289
|
+
* @param fullURL If provided, it will be our target, otherwise it is the current location.
|
|
290
|
+
*/
|
|
291
|
+
function removeSearchParams(keys, fullURL) {
|
|
292
|
+
const updatedURL = [];
|
|
293
|
+
const { origin, pathname, search, hash } = new URL(fullURL ?? window.location.href);
|
|
294
|
+
const searchParams = new URLSearchParams(search);
|
|
295
|
+
for (const key of keys) {
|
|
296
|
+
searchParams.delete(key);
|
|
297
|
+
}
|
|
298
|
+
updatedURL.push(origin, pathname);
|
|
299
|
+
if (searchParams.toString() !== '') {
|
|
300
|
+
updatedURL.push('?', searchParams.toString());
|
|
301
|
+
}
|
|
302
|
+
if (hash !== '') {
|
|
303
|
+
updatedURL.push(hash);
|
|
304
|
+
}
|
|
305
|
+
return updatedURL.join('');
|
|
306
|
+
}
|
|
287
307
|
|
|
288
308
|
function addStyle(css, parent = document.documentElement) {
|
|
289
309
|
const style = document.createElement('style');
|
|
@@ -414,4 +434,4 @@ async function getOptions(flags) {
|
|
|
414
434
|
return options;
|
|
415
435
|
}
|
|
416
436
|
|
|
417
|
-
export { $, $$, addStyle, alert, asserted, capitalize, confirm, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, logId, noop, padZeros, pageLoad, prompt, remove, scriptName, setSearchParam, sleep, tabURL, toString };
|
|
437
|
+
export { $, $$, addStyle, alert, asserted, capitalize, confirm, fish, fishResponse, fishX, fishXResponse, getOptions, getSearchParam, imageLoad, isBoolean, isFalsy, isFunction, isNotNullish, isNullish, isNumber, isObject, isString, isTruthy, join, logId, noop, padZeros, pageLoad, prompt, remove, removeSearchParams, scriptName, setSearchParam, sleep, tabURL, toString };
|