Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sveltekit-search-params

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sveltekit-search-params - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

2

package.json
{
"name": "sveltekit-search-params",
"version": "0.1.7",
"version": "0.1.8",
"repository": "git+https://github.com/paoloricciuti/sveltekit-search-params.git",

@@ -5,0 +5,0 @@ "author": "Paolo Ricciuti",

@@ -74,2 +74,4 @@ /* eslint-disable @typescript-eslint/no-empty-function */

};
const batchedUpdates = new Set();
let batchTimeout;
export function queryParameters(options) {

@@ -82,17 +84,27 @@ const { set: _set, subscribe, update } = writable();

const query = new URLSearchParams($page.url.searchParams);
for (const field of Object.keys(value)) {
if (!value[field] == undefined) {
query.delete(field);
continue;
const toBatch = (query) => {
for (const field of Object.keys(value)) {
if (!value[field] == undefined) {
query.delete(field);
continue;
}
let fnToCall = (value) => value.toString();
const optionsKey = options?.[field];
if (typeof optionsKey !== "boolean" && typeof optionsKey?.encode === 'function') {
fnToCall = optionsKey.encode;
}
query.set(field, fnToCall(value[field]));
}
let fnToCall = (value) => value.toString();
const optionsKey = options?.[field];
if (typeof optionsKey !== "boolean" && typeof optionsKey?.encode === 'function') {
fnToCall = optionsKey.encode;
}
query.set(field, fnToCall(value[field]));
}
goto(`?${query}`, {
keepFocus: true,
noScroll: true
};
batchedUpdates.add(toBatch);
clearTimeout(batchTimeout);
batchTimeout = setTimeout(() => {
batchedUpdates.forEach((batched) => {
batched(query);
});
goto(`?${query}`, {
keepFocus: true,
noScroll: true,
});
batchedUpdates.clear();
});

@@ -126,12 +138,22 @@ };

setRef.value = (value) => {
const toBatch = (query) => {
if (value == undefined) {
query.delete(name);
}
else {
query.set(name, encode(value));
}
};
batchedUpdates.add(toBatch);
clearTimeout(batchTimeout);
const query = new URLSearchParams($page.url.searchParams);
if (value == undefined) {
query.delete(name);
}
else {
query.set(name, encode(value));
}
goto(`?${query}`, {
keepFocus: true,
noScroll: true,
batchTimeout = setTimeout(() => {
batchedUpdates.forEach((batched) => {
batched(query);
});
goto(`?${query}`, {
keepFocus: true,
noScroll: true,
});
batchedUpdates.clear();
});

@@ -138,0 +160,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc