@wbc-sprout/shared-react v1.0.1
Sprout Shared React Library
This is a repository for sprout shared react library
Installation
Run npm i @wbc-sprout/shared-react
to install with npm or yarn add @wbc-sprout/shared-react
to install with yarn
Configurations
regExp
Kind: global constant
Properties
Name | Type |
---|---|
NUMBER | RegExp |
POSITIVE_NUMBER | RegExp |
POSITIVE_NUMBER_DECIMAL_POINT | RegExp |
RegExp | |
PHONE_NUMBER | RegExp |
ALPHA_NUMERIC | RegExp |
ALPHA_NUMERIC_COMMA_DOT | RegExp |
ALPHA_NUMERIC_PLANE | RegExp |
PASSWORD | RegExp |
URL | RegExp |
Utility Functions
isTypeOf(varToCheck, type) ⇒ * | boolean
Kind: global function
Returns: * | boolean - check - the strict type of a variable
Param | Type | Description |
---|---|---|
varToCheck | * | variable to check its type |
type | string | The type to check against |
getDistinctFrequency(array) ⇒ Object
Kind: global function
Returns: Object - Frequency counter
Param | Type | Description |
---|---|---|
array | Array | string | The port to normalize |
isValidBase64Image(base64) ⇒ string | *
Check if a string is a valid base64
Kind: global function
Returns: string | * - If the string is base64 formatted
Param | Type | Description |
---|---|---|
base64 | string | the base 64 string |
pickFromObject(obj, acceptedKeys) ⇒ Object | *
To create a new object containing a specified key from an existing object
Kind: global function
Returns: Object | * - Newly created object
Param | Type | Description |
---|---|---|
obj | Object | object to pick key value pair from |
acceptedKeys | Array.<string> | the keys to pick from the object |
discardFromObject(obj, forbiddenKeys) ⇒ Object | *
To create a new object that does not contain a specified key from an existing object
Kind: global function
Returns: Object | * - Newly created object
Param | Type | Description |
---|---|---|
obj | Object | Object to create from |
forbiddenKeys | Array.<string> | the keys that should not exist in the new object |
leadingZero(num, size) ⇒ string
Kind: global function
Returns: string - Padded number
Param | Type | Default |
---|---|---|
num | number | |
size | number | 2 |
Cookie
Constants
Typedefs
Cookie
Kind: global class
new Cookie(method)
Returns: Object - Cookie Instance
Param | Type |
---|---|
method | string |
appCookie
Kind: global constant
Properties
Name | Type |
---|---|
init | CookieInit |
getObject | CookieGetObject |
removeAll | CookieRemoveAll |
getAll | CookieGetAll |
removeAllExcept | CookieRemoveAllExcept |
get | CookieGet |
putObject | CookiePutObject |
put | CookiePut |
remove | CookieRemove |
appLocalStorage
Kind: global constant
Properties
Name | Type |
---|---|
init | CookieInit |
getObject | CookieGetObject |
removeAll | CookieRemoveAll |
getAll | CookieGetAll |
removeAllExcept | CookieRemoveAllExcept |
get | CookieGet |
putObject | CookiePutObject |
put | CookiePut |
remove | CookieRemove |
CookieInit ⇒ *
To initialize cookie
Kind: global typedef
Returns: * - Null
CookieGet ⇒ *
To get data in cookie
Kind: global typedef
Returns: * - Cookie Data
Param | Type |
---|---|
key | string |
CookieGetObject ⇒ Object
To get object data in cookie
Kind: global typedef
Returns: Object - Cookie Data
Param | Type |
---|---|
key | string |
CookiePut ⇒ *
To put data in cookie
Kind: global typedef
Returns: * - Null
Param | Type | Default |
---|---|---|
key | string | |
value | string | |
path | string | "/" |
expireIn | number |
CookiePutObject ⇒ *
To put Object data in cookie
Kind: global typedef
Returns: * - Null
Param | Type | Default |
---|---|---|
key | string | |
value | string | |
path | string | "/" |
expireIn | number |
CookieRemoveAll ⇒ *
To remove all cookies
Kind: global typedef
Returns: * - Null
Param | Type | Default |
---|---|---|
path | string | "/" |
CookieRemoveAllExcept ⇒ *
To remove all cookies except specific ones
Kind: global typedef
Returns: * - Null
Param | Type | Default |
---|---|---|
exceptionKeys | Array.<string> | |
path | string | "/" |
CookieRemove ⇒ *
To remove a cookie by its key
Kind: global typedef
Returns: * - Null
Param | Type | Default |
---|---|---|
key | string | |
path | string | "/" |
CookieGetAll ⇒ Object
To get all cookie
Kind: global typedef
Returns: Object - Cookie Data
URLs
replaceDynamics(route, dynamic_obj, identifier) ⇒ string
Kind: global function
Returns: string - the url
Param | Type | Default |
---|---|---|
route | string | |
dynamic_obj | Object | |
identifier | string | "@" |
updateQueryParams(route, params, customIdentifier) ⇒ string
Kind: global function
Returns: string - The updated url with the query params attached
Param | Type |
---|---|
route | string |
params | Object |
customIdentifier | string |
extractQueryParams(uri) ⇒ Object
Kind: global function
Returns: Object - queryObject
Param | Type |
---|---|
uri | string |
hardRedirect(url) ⇒ *
Kind: global function
Returns: * - Null
Param | Type |
---|---|
url | string |
attachAccessTokenToUrlQueryParams(url) ⇒ string | *
Kind: global function
Returns: string | * - url
Param | Type |
---|---|
url | string |
attachPreviousQuery(url, checkFor) ⇒ string | *
Kind: global function
Returns: string | * - url
Param | Type | Description |
---|---|---|
url | string | URL |
checkFor | string | Previous query to attach |
Hooks
useRequest(config) ⇒ Array.<{makeRequest: function(), error: *}>
Kind: global function
Returns: Array.<{makeRequest: function(), error: *}> - Hook data
Param | Type |
---|---|
config | Object |
config.url | string |
config.method | string |
config.body | Object |
config.onSuccess | function |
config.onError | function |
makeRequest() ⇒ Promise.<*>
Kind: global function
Returns: Promise.<*> - The request data