1.2.0 • Published 7 months ago

common-handlers v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

Getting Started

Installation

npm install common-handlers --save

Finance

Format Amount

Returns the minified format of the amount passed

formatAmount(10000)

OUTPUT: { valueDisplay: 10, valueLabel: 'k' }

### Fixed Zero
> Converts the number in two digit format with 0 as default value
```console
fixedZero(8)

OUTPUT: '08'

Format Amount with Label

Returns the formatted amount

formatAmountWithLabel(1000, 'k')

OUTPUT: { formattedAmmount: 1, label: 'k', display: { key: 'thousand', text: 'Thousand' } }

### Rupee formatter
> Formats the rupee in US format
```console
rupeeFormatter(1000000)

OUTPUT: '10,00,000'

Time

Time Range

Calculates the date and time starting from current date and time using the input parameters Input paramerters can be: 1. day: calculates current + n days and returns the date 2. week: calculates current + n week and returns the date 3. month: calculates current + n months and returns the date 4. year: calculates current + n years and returns the date

timeRange('week', 1)  // 1 = number of weeks

OUTPUT: current dayjs object, next week dayjs object

### Time Display
> Coverts the seconds into human readable format (dd hh mm ss). If passed a type as "raw", then raw values are returned
```console
timeDisplayConverter(94452)

OUTPUT: 
1d 2h 14m 12s

timeRange(94452, 'raw')

OUTPUT: 
{
  days: 1,
  hours: 2,
  minutes: 14,
  seconds: 12
}

Common

Is Empty

Checks for empty variable, object or an array

Is Not Number

Checks for data which is not a number

Is Undefined

Checks for undefined variables

Changelogs

1.1.2

  1. Converted module from commonJS to ECMAScript
  2. Replace imports with following format
Old Way:
import timeDisplayConverter from 'common-handlers/time/timeDisplayConverter';

New Way:
import { timeDisplayConverter } from 'common-handlers';
1.2.0

7 months ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago