Pathname JS 🛣
Simply manage paths.
Install
npm install pathname-js
Usage
var Pathname = ; var pathname = "some/path/with/an/:id";pathnamestring;// => "some/path/with/an/:id" pathname2 = 'to';pathname3 = 'number';pathnameid = 4;pathnamestring;// => "some/path/to/number/4" pathname;pathnameletter = 'A';pathnamestring;// => "some/path/to/number/4/and/letter/A"
Array
Pathname ⇐ Kind: global class
Extends: Array
- Pathname ⇐
Array
- new Pathname(...parts)
- .root :
boolan
- .keys :
Array.<string>
- .clone :
Pathname
- .raw :
string
- .string :
string
- .toString() ⇒
string
- .match(pattern) ⇒
Array
- .replace(pattern) ⇒
Pathname
- .push(...parts) ⇒
Pathname
- .concat(...parts) ⇒
Pathname
- .clear() ⇒
Pathname
- .reset() ⇒
Pathname
new Pathname(...parts)
Create a Pathname object.
Param | Type | Description |
---|---|---|
...parts | string | Array |
Same value as concat's parameters. |
boolan
pathname.root : true
if the pathname is absolute, false
in the other case.
Kind: instance property of Pathname
Array.<string>
pathname.keys : The path parameter keys.
Kind: instance property of Pathname
Read only: true
Pathname
pathname.clone : A clone of the path.
Kind: instance property of Pathname
Read only: true
string
pathname.raw : Path string value, without replacing parameters by values.
Kind: instance property of Pathname
Read only: true
string
pathname.string : Path string value, with parameters replaced by values. When set, it can have new parameters.
Kind: instance property of Pathname
string
pathname.toString() ⇒ Kind: instance method of Pathname
Returns: string
- Value of Patname#string
Array
pathname.match(pattern) ⇒ Match a pattern on the path.
Kind: instance method of Pathname
Returns: Array
- The match result.
Param | Type | Description |
---|---|---|
pattern | RegExp |
The pattern to match. |
Pathname
pathname.replace(pattern) ⇒ Replace a pattern on the path.
Kind: instance method of Pathname
Returns: Pathname
- The replaced path.
Param | Type | Description |
---|---|---|
pattern | RegExp |
The pattern to replace. |
Pathname
pathname.push(...parts) ⇒ Same as Patname#concat
Kind: instance method of Pathname
Returns: Pathname
- Itself.
Param | Type | Description |
---|---|---|
...parts | Pathname | Array | string |
The parts to add to the path. |
Pathname
pathname.concat(...parts) ⇒ Adds parts to the path.
Kind: instance method of Pathname
Returns: Pathname
- Itself.
Param | Type | Description |
---|---|---|
...parts | Pathname | Array | string |
The parts to add to the path. |
Pathname
pathname.clear() ⇒ Empty the path.
Kind: instance method of Pathname
Returns: Pathname
- Itself.
Pathname
pathname.reset() ⇒ Set all the path parameters to null.
Kind: instance method of Pathname
Returns: Pathname
- Itself.