mirror of
https://github.com/dzeiocom/libs.git
synced 2025-04-22 10:52:11 +00:00
Finished JSDoc (#22)
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
c711f5526e
commit
3f5616ec29
@ -1,6 +1,6 @@
|
|||||||
# URL Manager
|
# URL Manager
|
||||||
|
|
||||||
simple to use yet powerful Urls parser and formatter
|
A simple to use yet complete Urls parser and serializer
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -23,9 +23,7 @@ const URLManager = require('@dzeio/url-manager').default
|
|||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
// Create a new instance
|
// Create a new instance
|
||||||
const url = new URLManager() // you can have an URL, URLSearchParams Objects or a string as parameter
|
const url = new URLManager(/* Optionnal */ baseUrl) // you can have an URL, URLSearchParams Objects or a string as parameter
|
||||||
// or
|
|
||||||
const url = URLManager.fromLocation() // Browser only return a new instance from the current location
|
|
||||||
```
|
```
|
||||||
|
|
||||||
- manipulate the url
|
- manipulate the url
|
||||||
@ -33,6 +31,7 @@ const url = URLManager.fromLocation() // Browser only return a new instance from
|
|||||||
```typescript
|
```typescript
|
||||||
|
|
||||||
// Get set delete query
|
// Get set delete query
|
||||||
|
url.query() // get an object containing everything
|
||||||
url.query("sort") // get
|
url.query("sort") // get
|
||||||
url.query("sort", 'value') // set
|
url.query("sort", 'value') // set
|
||||||
url.query("sort", null) // delete
|
url.query("sort", null) // delete
|
||||||
@ -73,19 +72,10 @@ url.hash('i-am-a-hash') // set
|
|||||||
- format it back to a string
|
- format it back to a string
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
|
url.toString() // => the serialized URL
|
||||||
url.toString()
|
|
||||||
`${url}`
|
|
||||||
|
|
||||||
// NOTE: if the path contains elements like [param]
|
// NOTE: if the path contains elements like [param]
|
||||||
// you can replace them in the toString function like this
|
// you can replace them in the toString function like this
|
||||||
|
// /pouet/[param] => /pouet/test
|
||||||
url.toString({param: 'test'})
|
url.toString({param: 'test'})
|
||||||
```
|
```
|
||||||
|
|
||||||
- you have also two "util" functions (Available only in the browser)
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
url.reload() // reload the current page
|
|
||||||
url.go() // go to the url
|
|
||||||
url.go(false) // show the next url in the browser without changing the content of the document
|
|
||||||
```
|
|
||||||
|
@ -1,13 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "@dzeio/url-manager",
|
"name": "@dzeio/url-manager",
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"description": "Manage URL",
|
"description": "A simple to use yet complete Urls parser and serializer",
|
||||||
"repository": "https://github.com/dzeiocom/libs.git",
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/dzeiocom/libs.git",
|
||||||
|
"directory": "packages/url-manager"
|
||||||
|
},
|
||||||
"homepage": "https://github.com/dzeiocom/libs/tree/master/packages/url-manager#readme",
|
"homepage": "https://github.com/dzeiocom/libs/tree/master/packages/url-manager#readme",
|
||||||
"author": "Aviortheking",
|
"author": "Aviortheking",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "./dist/URLManager.js",
|
"main": "./dist/URLManager.js",
|
||||||
"types": "./dist/URLManager.d.ts",
|
"types": "./dist/URLManager.d.ts",
|
||||||
|
"keywords": [
|
||||||
|
"url",
|
||||||
|
"url-manager",
|
||||||
|
"url serializer",
|
||||||
|
"url parser",
|
||||||
|
"parser",
|
||||||
|
"serializer"
|
||||||
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chai": "^4.2.12",
|
"@types/chai": "^4.2.12",
|
||||||
"@types/jest": "^26.0.10",
|
"@types/jest": "^26.0.10",
|
||||||
|
@ -61,7 +61,7 @@ export default class URLManager {
|
|||||||
/**
|
/**
|
||||||
* set/delete a key to a value in the query string
|
* set/delete a key to a value in the query string
|
||||||
* @param key the key to set/delete
|
* @param key the key to set/delete
|
||||||
* @param value the value to set or null to delete it
|
* @param value the value to set or `null` to delete it
|
||||||
*/
|
*/
|
||||||
public query(key: string, value: string | Array<string> | null): this
|
public query(key: string, value: string | Array<string> | null): this
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user