1.0.14 • Published 1 year ago

usual_fn v1.0.14

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

usual_fn

Commonly used functions

Features

  • formatDate: Format the date in the local format of your choice
  • formatPhone : Format the phone number with/without prefix
  • formatPrice : Format the amount in human readable format

Installation

npm i usual_fn

formatDate

Format the date in the local format of your choice

formatDate(options: FormatDateOptions): string

interface FormatDateOptions {
  data: string | Date | number;
  $locale?: string;
  $t?: (arg: string) => string;
  key?: string;
}
// Example

import { formatDate } from "usual_fn";

const formattedDate = formatDate({
  data: new Date(),
});

const formattedNow = formatDate({
  data: Date.now(),
});

console.log(formattedDate);
console.log(formattedNow);

formatPhone

Format the phone number with/without prefix

formatPhoneWithPrefixe(params: FormatPhone): string

formatPhone(params: FormatPhone): string

interface FormatPhone {
  data: string;
}
// Example

import { formatPhone, formatPhoneWithPrefixe } from "usual_fn";

const formattedPhoneWithPrefix = formatPhoneWithPrefixe({
  data: "22997000000",
});
const formattedPhone = formatPhone({
  data: "97000000",
});

console.log(formatedPhoneWithPrefix);
console.log(formatedPhone);

formatPrice

Format the amount in human readable format

formatPrice(params: FormatPrice): string

interface FormatPrice {
  amount: string | number;
  currency?: Boolean;
  device?: string;
}
// Example

import { formatPrice } from "usual_fn";

const amount = formatPrice({
  amount: 10000000,
  currency: true,
  device: "F CFA",
});

console.log(amount);
1.0.9

1 year ago

1.0.8

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago