Skip to content

Commit

Permalink
Merge branch 'main' into sam@api/prettier_object_logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-finch-tezos authored Oct 24, 2023
2 parents b5263a6 + 1c0b037 commit 400168a
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: daily
commit-message:
prefix: "Deps (NPM)"
- package-ecosystem: npm
directory: /packages/jstz/
schedule:
interval: daily
commit-message:
prefix: "Deps (NPM)"
- package-ecosystem: npm
directory: /packages/jstz-types/
schedule:
interval: daily
commit-message:
prefix: "Deps (NPM)"
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
commit-message:
prefix: "Deps (Actions)"
- package-ecosystem: cargo
directory: /
schedule:
interval: daily
commit-message:
prefix: "Deps (Cargo)"
- package-ecosystem: cargo
directory: /jstz_api/
schedule:
interval: daily
commit-message:
prefix: "Deps (Cargo)"
- package-ecosystem: cargo
directory: /jstz_cli/
schedule:
interval: daily
commit-message:
prefix: "Deps (Cargo)"
- package-ecosystem: cargo
directory: /jstz_core/
schedule:
interval: daily
commit-message:
prefix: "Deps (Cargo)"
- package-ecosystem: cargo
directory: /jstz_crypto/
schedule:
interval: daily
commit-message:
prefix: "Deps (Cargo)"
- package-ecosystem: cargo
directory: /jstz_kernel/
schedule:
interval: daily
commit-message:
prefix: "Deps (Cargo)"
- package-ecosystem: cargo
directory: /jstz_proto/
schedule:
interval: daily
commit-message:
prefix: "Deps (Cargo)"
1 change: 1 addition & 0 deletions docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default defineConfig({
{ text: "Ledger", link: "/api/ledger" },
{ text: "Headers", link: "/api/headers" },
{ text: "Response", link: "/api/response" },
{ text: "URLSearchParams", link: "/api/url_search_params" },
],
},
],
Expand Down
92 changes: 92 additions & 0 deletions docs/api/url_search_params.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# 🔗 URLSearchParams

`jstz`'s implementation of the `URLSearchParams` API defines utility methods for working with the query string of a URL according to the [URL specification](https://url.spec.whatwg.org/#urlsearchparams). It is used for building and manipulating search parameters.

## Example

```typescript
// Parse query string from URL
let url = new URL("https://example.com?foo=1&bar=2");
let params = new UrlSearchParams(url.search);

// Add a new parameter
params.append("baz", 3);

// Remove parameter
params.delete("bar");
```

## Constructor

### `new UrlSearchParams(init?: [string, string][] | Record<string, string> | string)`

Creates a new instance of `UrlSearchParams` with the provided key-value pairs.

- **init**:
One of:
- An array of key-value pairs. Each pair is an array where the first element is the key (Name) and the second is the value.
- A record of string keys and string values.
- A string, which will be parsed from application/x-www-form-urlencoded format. A leading '?' character is ignored.

## Instance Properties

### `readonly size: number`

- **Returns**: The number of search parameters present.

## Instance Methods

### `append(name: string, value: string): void`

Appends a specified key/value pair as a new search parameter.

- **name**: The name of the search parameter.
- **value**: The value of the search parameter.

### `delete(name: string, value?: string): void`

Removes search parameters that match the given name. If a value is provided, only parameters with that name-value pair are removed.

- **name**: The name of the search parameter to be removed.
- **value** (optional): The specific value of the search parameter to be removed.

### `get(name: string): string | null`

Returns the first value associated with the given search parameter.

- **name**: The name of the search parameter.

- **Returns**: The value associated with the given search parameter or `null` if not found.

### `getAll(name: string): string[]`

Returns all the values associated with a given search parameter.

- **name**: The name of the search parameter.

- **Returns**: An array of values associated with the given search parameter.

### `has(name: string, value?: string): boolean`

Determines whether the `UrlSearchParams` object has a certain parameter, optionally with a specific value.

- **name**: The name of the parameter you want to check for.
- **value** (optional): The value of the parameter you want to check for.
- **Returns**: `true` if the parameter, or parameter-value pair, exists. Otherwise, returns `false`.

### `set(name: string, value: string): void`

Sets the value associated with a given parameter. If there are several matching parameters, it updates the first and removes the others.

- **name**: The name of the parameter you want to set or update.
- **value**: The new value for the parameter.

If the parameter does not exist, this method will append the parameter-value pair.

### `sort(): void`

Sorts all key/value pairs in the `UrlSearchParams` object by their keys. The sorting is done by comparing the code units of the keys. The relative order between pairs with equal names is preserved.

### `toString(): string`

Returns a query string suitable for use in a URL.

0 comments on commit 400168a

Please sign in to comment.