Function
| Static Public Summary | ||
| public |
clearAll() Clear all data stored in local storage |
|
| public |
convertHexToRgb(color: string): string Coverts any HEX color code to RGB |
|
| public |
convertPixelRangeToArray(str: string): array Convert pixel range to list of pixels |
|
| public |
deduplicateArray(arr: array): array Deduplicates any array |
|
| public |
getKey(key: string): string Get the data stored in specific key of local storage |
|
| public |
isValidFontSize(str: string): boolean Validate if user input is a valid font size |
|
| public |
isValidPositiveInteger(str: string): boolean Validate if user input is a positive integer |
|
| public |
removeExtraSpacesAndCommas(str: string): string Remove multiple consecutive spaces, trialing space and comma |
|
| public |
removeKey(key: string) Remove the data stored in specific key of local storage |
|
| public |
roundToNearest(value: number, precision: number): number Coverts any HEX color code to RGB |
|
| public |
setKey(key: string, data: *) Store data to local storage when key is provided |
|
| public |
sortArrayAscending(arr: array): array Sort array in ascending order |
|
| public |
useDebounce(value: *, delay: number): * A hook which used for debounce states for a certain amount of time(ms) |
|
Static Public
public convertHexToRgb(color: string): string source
import convertHexToRgb from 'px2em-converter/src/utils/color.utils.js'Coverts any HEX color code to RGB
Params:
| Name | Type | Attribute | Description |
| color | string | HEX color |
Return:
| string | RGB value |
public convertPixelRangeToArray(str: string): array source
import {convertPixelRangeToArray} from 'px2em-converter/src/utils/format.utils.js'Convert pixel range to list of pixels
Params:
| Name | Type | Attribute | Description |
| str | string | Pixel range, e.g. |
Return:
| array | List of pixels, e.g. |
public deduplicateArray(arr: array): array source
import {deduplicateArray} from 'px2em-converter/src/utils/format.utils.js'Deduplicates any array
Params:
| Name | Type | Attribute | Description |
| arr | array | Array to be deduplicated |
Return:
| array | Deduplicated array If |
public getKey(key: string): string source
Get the data stored in specific key of local storage
Params:
| Name | Type | Attribute | Description |
| key | string | Local storage key which specifies where the data to be stored |
Return:
| string | Data stored in |
Return Properties:
| Name | Type | Attribute | Description |
| localStorageUtils | function() | Helpers for interacting with local storage |
public isValidFontSize(str: string): boolean source
import {isValidFontSize} from 'px2em-converter/src/utils/validate.utils.js'Validate if user input is a valid font size
Params:
| Name | Type | Attribute | Description |
| str | string | User input |
Return:
| boolean |
|
public isValidPositiveInteger(str: string): boolean source
import {isValidPositiveInteger} from 'px2em-converter/src/utils/validate.utils.js'Validate if user input is a positive integer
Params:
| Name | Type | Attribute | Description |
| str | string | User input |
Return:
| boolean |
|
public removeExtraSpacesAndCommas(str: string): string source
import {removeExtraSpacesAndCommas} from 'px2em-converter/src/utils/format.utils.js'Remove multiple consecutive spaces, trialing space and comma
Params:
| Name | Type | Attribute | Description |
| str | string | String to process |
Return:
| string | String which its multiple consecutive spaces, trialing space and comma are removed |
public removeKey(key: string) source
Remove the data stored in specific key of local storage
Params:
| Name | Type | Attribute | Description |
| key | string | Local storage key which specifies where the data to be stored |
public roundToNearest(value: number, precision: number): number source
import {roundToNearest} from 'px2em-converter/src/utils/format.utils.js'Coverts any HEX color code to RGB
Params:
| Name | Type | Attribute | Description |
| value | number | Interger / floating point value that needs to be rounded |
|
| precision | number | Number of decimal places |
Return:
| number | Rounded floating point value |
public setKey(key: string, data: *) source
Store data to local storage when key is provided
Params:
| Name | Type | Attribute | Description |
| key | string | Local storage key which specifies where the data to be stored |
|
| data | * | Data to store to local storage |
public sortArrayAscending(arr: array): array source
Sort array in ascending order
Params:
| Name | Type | Attribute | Description |
| arr | array | Array to sort |
Return:
| array | Array sorted in ascending order |
public useDebounce(value: *, delay: number): * source
import useDebounce from 'px2em-converter/src/hooks/useDebounce.js'A hook which used for debounce states for a certain amount of time(ms)
Params:
| Name | Type | Attribute | Description |
| value | * | state value |
|
| delay | number | debounce in milliseconds |
Return:
| * | latest value of state |
Reference
Source
Test