new QueryHash(dataopt) → {QueryHash}
Create an instance of QueryHash
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
string | object |
<optional> |
base to create key-value items; base64 string, query string, or plain object |
- Source:
Throws:
Error
Returns:
this, chainable
- Type
- QueryHash
Methods
add(key, val) → {QueryHash}
Add a key-value pair
Parameters:
Name | Type | Description |
---|---|---|
key |
string | item key to add |
val |
string | number | boolean | item value |
- Source:
Throws:
Error
Returns:
this, chainable
- Type
- QueryHash
find(key) → {Array.<QueryHashItem>}
Find items with a given key
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Item key to find |
- Source:
Throws:
Error
Returns:
- Type
- Array.<QueryHashItem>
first(key) → {string|null}
Return the first value found matching the given key. Useful when keys are unique.
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Return the item value with this key |
- Source:
Returns:
- Type
- string | null
fromObject(obj) → {QueryHash}
Add items to instance, only keys with primitive values will be added
Parameters:
Name | Type | Description |
---|---|---|
obj |
object | A plain object with no nested/reference values |
- Source:
Throws:
Error
Returns:
this, chainable
- Type
- QueryHash
fromQueryString(qs) → {QueryHash}
Add items to instance from a query string
Parameters:
Name | Type | Description |
---|---|---|
qs |
string | a valid query string |
- Source:
Throws:
Error
Returns:
this, chainable
- Type
- QueryHash
fromUrlToken(urlToken) → {QueryHash}
Add items to instance from base64 query string
Parameters:
Name | Type | Description |
---|---|---|
urlToken |
string | a base64 encoded query string |
- Source:
Throws:
Error
Returns:
this, chainable
- Type
- QueryHash
has(key) → {boolean}
Test whether or not an item exists by its key
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Item key to test |
- Source:
Returns:
- Type
- boolean
keys() → {Array}
Return an array of unique item keys
- Source:
Returns:
- Type
- Array
remove(key) → {QueryHash}
Remove items matching the given key
Parameters:
Name | Type | Description |
---|---|---|
key |
string | Item key to remove |
- Source:
Throws:
Error
Returns:
this, chainable
- Type
- QueryHash
toQueryString() → {string}
Return a valid query string composed of instance items
- Source:
Returns:
- Type
- string
toUrlToken() → {string}
Return a base64 encoded query string
- Source:
Returns:
- Type
- string