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

kit-query-params

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kit-query-params - npm Package Compare versions

Comparing version 0.0.25 to 0.0.26

1

dist/index.svelte.d.ts

@@ -6,2 +6,3 @@ import { SvelteURLSearchParams } from 'svelte/reactivity';

$reset: (enforceDefault?: boolean) => void;
$sync: () => void;
};

12

dist/index.svelte.js

@@ -60,3 +60,3 @@ import { SvelteURLSearchParams } from 'svelte/reactivity';

});
const updateLocation = debounce(() => {
const sync = () => {
cleanUnknownParams();

@@ -83,3 +83,4 @@ const query = searchParams.toString();

}
}, debounceTime);
};
const debouncedSync = debounce(sync, debounceTime);
const reset = (_enforceDefault = enforceDefault) => {

@@ -93,3 +94,3 @@ Array.from(searchParams.keys()).forEach((key) => {

Object.assign(current, parseURL(searchParams, schema, _enforceDefault ? defaultValue : undefined));
updateLocation();
debouncedSync();
};

@@ -103,3 +104,3 @@ const updateSearchParams = (key, stringified) => {

}
updateLocation();
debouncedSync();
};

@@ -115,3 +116,3 @@ return createProxy(current, {

});
updateLocation();
debouncedSync();
},

@@ -121,4 +122,5 @@ default: defaultValue,

searchParams,
sync,
reset
});
};
import type { SvelteURLSearchParams } from 'svelte/reactivity';
import type { Default, Schema, SchemaOutput, Simplify } from './types.js';
export declare const createProxy: <T extends Schema, D extends Default<T> | undefined, Enforce extends boolean = false>(obj: any, { schema, onUpdate, clearPaths, searchParams, reset, path, array, default: defaultValue, enforceDefault }: {
export declare const createProxy: <T extends Schema, D extends Default<T> | undefined, Enforce extends boolean = false>(obj: any, { schema, onUpdate, clearPaths, searchParams, reset, path, array, default: defaultValue, sync, enforceDefault }: {
schema: T;
enforceDefault?: boolean;
onUpdate: (path: string, value: any) => void;
sync: () => void;
clearPaths?: (path: string) => void;

@@ -16,2 +17,3 @@ searchParams: SvelteURLSearchParams | URLSearchParams;

$reset: (enforceDefault?: boolean) => void;
$sync: () => void;
};
import { stringifyPrimitive, isPrimitive } from './utils.js';
import { traverseSchema } from './traverse.js';
import { coerceArray, coerceObject, coercePrimitive, coercePrimitiveArray } from './coerce.js';
export const createProxy = (obj, { schema, onUpdate, clearPaths = () => { }, searchParams, reset, path = '', array, default: defaultValue, enforceDefault }) => {
export const createProxy = (obj, { schema, onUpdate, clearPaths = () => { }, searchParams, reset, path = '', array, default: defaultValue, sync, enforceDefault }) => {
const handler = {

@@ -13,2 +13,5 @@ get(target, key) {

}
if (key === '$sync') {
return sync;
}
const value = Reflect.get(target, key);

@@ -70,2 +73,3 @@ if (array) {

clearPaths,
sync,
reset,

@@ -72,0 +76,0 @@ path: path ? `${path}.${key}` : key,

@@ -18,3 +18,3 @@ export type ConditionalSimplifyDeep<Type, ExcludeType = never, IncludeType = unknown> = Type extends ExcludeType ? Type : Type extends IncludeType ? {

enforceDefault?: Enforce;
debounce?: number;
debounce?: number | false;
pushHistory?: boolean;

@@ -21,0 +21,0 @@ twoWayBinding?: boolean;

import type { SvelteURLSearchParams } from 'svelte/reactivity';
import type { Default, Primitive, Schema, SchemaOutput } from './types.js';
export declare const debounce: (fn: () => void, delay: number) => () => void;
export declare const debounce: (fn: () => void, delay: number | false) => () => void;
export declare const stringifyPrimitive: (primitiveType: Primitive, value: any) => string | null;

@@ -5,0 +5,0 @@ export declare const parseURL: <S extends Schema, D extends Default<S> | undefined, Enforce extends boolean = false>(data: string | URL | URLSearchParams | SvelteURLSearchParams, schema: S, defaultValue?: D) => SchemaOutput<S, D, Enforce>;

import { coercePrimitive, validateEnum } from './coerce.js';
export const debounce = (fn, delay) => {
let timeout;
// if no delay, no debounce
if (delay === false) {
return () => { };
}
return () => {

@@ -5,0 +9,0 @@ clearTimeout(timeout);

{
"name": "kit-query-params",
"version": "0.0.25",
"version": "0.0.26",
"scripts": {
"dev": "vite dev",
"build": "vite build && npm run package",
"build": "vite build && npm ru0.àn package",
"preview": "vite preview",

@@ -8,0 +8,0 @@ "package": "svelte-kit sync && svelte-package && publint",

@@ -78,14 +78,14 @@ # kit-query-params

| Name | Type | Description | Default Value | Required | Example |
| --------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | -------- | ---------------------------------------- |
| schema | [`Schema`](#schemas) | Defines the structure and types of the URL parameters | | `true` | `{ search: 'string', tags: ["number"] }` |
| debounce | `number` | Time in milliseconds to wait before updating the URL after a state change | `200` | `false` | `500` |
| pushHistory | `boolean` | Whether to push a new history entry on state change | `false` | `false` | `true` |
| twoWayBinding | `boolean` | Enables synchronization between URL changes and state | `true` | `false` | `false` |
| preserveUnknownParams | `boolean` | Keeps URL parameters not defined in the schema | `true` | `false` | `false` |
| invalidateAll | `boolean` | Invalidates the state and re-fetches all load functions on state change | `false` | `false` | `false` |
| invalidate | `(string / URL)`[] | Other routes / load functions to invalidate on state change | `[]` | `false` | `["profile", "user"]` |
| shallow | `boolean` | If true, will not trigger a navigation and therefore not rerun the current load function | `false` | `false` | `true` |
| default | the type of your schema | The default value of the state. It will be used to initialize the state if no value is found in the url | `undefined` | `false` | `{ search: 'hello', tags: [1, 2] }` |
| enforceDefault | `boolean` | If true, will enforce the default value when a value is set to null or when the state is `$reset`. This led to removing `null` from the types of the values defined in your default | `false` | `false` | `true` |
| Name | Type | Description | Default Value | Required | Example |
| --------------------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | -------- | ---------------------------------------- |
| schema | [`Schema`](#schemas) | Defines the structure and types of the URL parameters | | `true` | `{ search: 'string', tags: ["number"] }` |
| debounce | `number` or `false` | Time in milliseconds to wait before updating the URL after a state change. If false the url will be updated on each state change and you will want to use the $sync method to manually update it. | `200` | `false` | `500` |
| pushHistory | `boolean` | Whether to push a new history entry on state change | `false` | `false` | `true` |
| twoWayBinding | `boolean` | Enables synchronization between URL changes and state | `true` | `false` | `false` |
| preserveUnknownParams | `boolean` | Keeps URL parameters not defined in the schema | `true` | `false` | `false` |
| invalidateAll | `boolean` | Invalidates the state and re-fetches all load functions on state change | `false` | `false` | `false` |
| invalidate | `(string / URL)`[] | Other routes / load functions to invalidate on state change | `[]` | `false` | `["profile", "user"]` |
| shallow | `boolean` | If true, will not trigger a navigation and therefore not rerun the current load function | `false` | `false` | `true` |
| default | the type of your schema | The default value of the state. It will be used to initialize the state if no value is found in the url | `undefined` | `false` | `{ search: 'hello', tags: [1, 2] }` |
| enforceDefault | `boolean` | If true, will enforce the default value when a value is set to null or when the state is `$reset`. This led to removing `null` from the types of the values defined in your default | `false` | `false` | `true` |

@@ -157,2 +157,3 @@ ### Schema

- a `$queryParams` property that is the underlying `SvelteURLqueryParams` reactive URLqueryParams
- a `$sync` method to manually update the url

@@ -159,0 +160,0 @@ ## 4. Server Side

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