1.0.1 • Published 4 years ago

@wbc-sprout/shared-react v1.0.1

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
4 years ago

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

NameType
NUMBERRegExp
POSITIVE_NUMBERRegExp
POSITIVE_NUMBER_DECIMAL_POINTRegExp
EMAILRegExp
PHONE_NUMBERRegExp
ALPHA_NUMERICRegExp
ALPHA_NUMERIC_COMMA_DOTRegExp
ALPHA_NUMERIC_PLANERegExp
PASSWORDRegExp
URLRegExp

Utility Functions

isTypeOf(varToCheck, type) ⇒ * | boolean

Kind: global function
Returns: * | boolean - check - the strict type of a variable

ParamTypeDescription
varToCheck*variable to check its type
typestringThe type to check against

getDistinctFrequency(array) ⇒ Object

Kind: global function
Returns: Object - Frequency counter

ParamTypeDescription
arrayArray | stringThe 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

ParamTypeDescription
base64stringthe 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

ParamTypeDescription
objObjectobject to pick key value pair from
acceptedKeysArray.<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

ParamTypeDescription
objObjectObject to create from
forbiddenKeysArray.<string>the keys that should not exist in the new object

leadingZero(num, size) ⇒ string

Kind: global function
Returns: string - Padded number

ParamTypeDefault
numnumber
sizenumber2

Cookie

Constants

Typedefs

Cookie

Kind: global class

new Cookie(method)

Returns: Object - Cookie Instance

ParamType
methodstring

appCookie

Kind: global constant
Properties

NameType
initCookieInit
getObjectCookieGetObject
removeAllCookieRemoveAll
getAllCookieGetAll
removeAllExceptCookieRemoveAllExcept
getCookieGet
putObjectCookiePutObject
putCookiePut
removeCookieRemove

appLocalStorage

Kind: global constant
Properties

NameType
initCookieInit
getObjectCookieGetObject
removeAllCookieRemoveAll
getAllCookieGetAll
removeAllExceptCookieRemoveAllExcept
getCookieGet
putObjectCookiePutObject
putCookiePut
removeCookieRemove

CookieInit ⇒ *

To initialize cookie

Kind: global typedef
Returns: * - Null

CookieGet ⇒ *

To get data in cookie

Kind: global typedef
Returns: * - Cookie Data

ParamType
keystring

CookieGetObject ⇒ Object

To get object data in cookie

Kind: global typedef
Returns: Object - Cookie Data

ParamType
keystring

CookiePut ⇒ *

To put data in cookie

Kind: global typedef
Returns: * - Null

ParamTypeDefault
keystring
valuestring
pathstring"/"
expireInnumber

CookiePutObject ⇒ *

To put Object data in cookie

Kind: global typedef
Returns: * - Null

ParamTypeDefault
keystring
valuestring
pathstring"/"
expireInnumber

CookieRemoveAll ⇒ *

To remove all cookies

Kind: global typedef
Returns: * - Null

ParamTypeDefault
pathstring"/"

CookieRemoveAllExcept ⇒ *

To remove all cookies except specific ones

Kind: global typedef
Returns: * - Null

ParamTypeDefault
exceptionKeysArray.<string>
pathstring"/"

CookieRemove ⇒ *

To remove a cookie by its key

Kind: global typedef
Returns: * - Null

ParamTypeDefault
keystring
pathstring"/"

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

ParamTypeDefault
routestring
dynamic_objObject
identifierstring"@"

updateQueryParams(route, params, customIdentifier) ⇒ string

Kind: global function
Returns: string - The updated url with the query params attached

ParamType
routestring
paramsObject
customIdentifierstring

extractQueryParams(uri) ⇒ Object

Kind: global function
Returns: Object - queryObject

ParamType
uristring

hardRedirect(url) ⇒ *

Kind: global function
Returns: * - Null

ParamType
urlstring

attachAccessTokenToUrlQueryParams(url) ⇒ string | *

Kind: global function
Returns: string | * - url

ParamType
urlstring

attachPreviousQuery(url, checkFor) ⇒ string | *

Kind: global function
Returns: string | * - url

ParamTypeDescription
urlstringURL
checkForstringPrevious query to attach

Hooks

useRequest(config) ⇒ Array.<{makeRequest: function(), error: *}>

Kind: global function
Returns: Array.<{makeRequest: function(), error: *}> - Hook data

ParamType
configObject
config.urlstring
config.methodstring
config.bodyObject
config.onSuccessfunction
config.onErrorfunction

makeRequest() ⇒ Promise.<*>

Kind: global function
Returns: Promise.<*> - The request data

1.0.1

4 years ago

1.0.0

4 years ago