mig-data-tools
v1.0.1
Published
This package provides common function which can be re-used in other different projects.
Downloads
120
Keywords
Readme
mig-data-tools
This package provides common function which can be re-used in other different projects.
Installation
npm install --save mig-data-tools
Usage
Url hash
The urlHash variable will provide a parsed version of the location hash in an object format.
import {parseLocationHash,serializeLocationHash} from 'mig-data-tools';
const parsedHash = parseLocationHash(`#%7B%22sortColumn%22%3A%22displayName%22%2C%22sortAsc%22%3Atrue%7D`)
# returns { sortColumn: 'displayName', sortAsc: true }
const urlHash= serializeLocationHash({ sortColumn: 'displayName', sortAsc: true });
# return `%7B%22sortColumn%22%3A%22displayName%22%2C%22sortAsc%22%3Atrue%7D`
String
import {unCamel} from 'mig-data-tools';
const text= unCamel('camelCase');
# return 'Camel Case'
Date timezone conversion
It helps to do the conversion of a date. Currently it only supports Asia/Jakarta and Europe/Amsterdam
import {localeFormatInTimeZone,alternativeTimeZone} from 'mig-data-tools';
const alternateTime= localeFormatInTimeZone(new Date(), alternativeTimeZone);
# return the date in alternative timezone