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
|
||||
|
||||
simple to use yet powerful Urls parser and formatter
|
||||
A simple to use yet complete Urls parser and serializer
|
||||
|
||||
## Usage
|
||||
|
||||
@ -23,9 +23,7 @@ const URLManager = require('@dzeio/url-manager').default
|
||||
|
||||
```typescript
|
||||
// Create a new instance
|
||||
const url = new URLManager() // 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
|
||||
const url = new URLManager(/* Optionnal */ baseUrl) // you can have an URL, URLSearchParams Objects or a string as parameter
|
||||
```
|
||||
|
||||
- manipulate the url
|
||||
@ -33,6 +31,7 @@ const url = URLManager.fromLocation() // Browser only return a new instance from
|
||||
```typescript
|
||||
|
||||
// Get set delete query
|
||||
url.query() // get an object containing everything
|
||||
url.query("sort") // get
|
||||
url.query("sort", 'value') // set
|
||||
url.query("sort", null) // delete
|
||||
@ -73,19 +72,10 @@ url.hash('i-am-a-hash') // set
|
||||
- format it back to a string
|
||||
|
||||
```typescript
|
||||
|
||||
url.toString()
|
||||
`${url}`
|
||||
url.toString() // => the serialized URL
|
||||
|
||||
// NOTE: if the path contains elements like [param]
|
||||
// you can replace them in the toString function like this
|
||||
// /pouet/[param] => /pouet/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",
|
||||
"version": "1.0.5",
|
||||
"description": "Manage URL",
|
||||
"repository": "https://github.com/dzeiocom/libs.git",
|
||||
"description": "A simple to use yet complete Urls parser and serializer",
|
||||
"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",
|
||||
"author": "Aviortheking",
|
||||
"license": "MIT",
|
||||
"main": "./dist/URLManager.js",
|
||||
"types": "./dist/URLManager.d.ts",
|
||||
"keywords": [
|
||||
"url",
|
||||
"url-manager",
|
||||
"url serializer",
|
||||
"url parser",
|
||||
"parser",
|
||||
"serializer"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/chai": "^4.2.12",
|
||||
"@types/jest": "^26.0.10",
|
||||
|
@ -61,7 +61,7 @@ export default class URLManager {
|
||||
/**
|
||||
* set/delete a key to a value in the query string
|
||||
* @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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user