   
!statement coverage
!line coverage
!function coverage
!branch coverage
This is a collection of tiny but useful utilities that we find ourselves using across our frontend clients.
- TypeScript
- Jest
- Prettier
- ESLint
``bash`
$ npm install @twigaeng/utils
`js`
// usage with default options
import { formatDate } from "@twigaeng/utils";
const formatedDate = formatDate("12-12-2020");
console.log(formatedDate); // Dec 2020
`js`
//usage with options
import { formatDate } from "@twigaeng/utils";
const formatedDate = formatDate("12-12-2020", {
weekday: "short",
month: "short",
year: "numeric",
});
console.log(formatedDate); // Dec 2020 Sat
`js`
// usage with locale option
import { formatDate } from "@twigaeng/utils";
const formatedDate = formatDate(
"12-12-2020",
{
weekday: "short",
month: "short",
year: "numeric",
},
"de-DE"
);
console.log(formatedDate); // Dez. 2020 Sa
`js`
import { formatCurrency } from "@twigaeng/utils";
const currency = formatCurrency(400);
console.log(currency); // KSH 400
`js`
// usage with currency option
import { formatCurrency } from "@twigaeng/utils";
const currency = formatCurrency(400, "USD");
console.log(currency); // $400
`js`
// usage with currency and locale option
import { formatCurrency } from "@twigaeng/utils";
const currency = formatCurrency("400", "JPY", "ja-JP");
console.log(currency); // ¥400
- Linting via ESLint.
- Run manually via yarn lint.import ... from ...
- Integrates with Visual Studio Code via vscode-eslint.
- Highlights type & linting issues.
- Provides debuging options for running Jest tests (once and in watch mode).
- Uses AirBNB ESLint plugin as sane defaults.
- statements are verified for correctness via eslint-plugin-import.yarn format
- Formatting via Prettier.
- Run manually via .
- Integrates well with Visual Studio Code via prettier-vscode.
- Automatically formats on save.
- yarn test -- Runs tests.yarn typecheck
- -- Checks TypeScript types for correctness. This is disabled during tests for performance reasons.yarn lint
- -- Runs linting.yarn format
- -- Reformats all of the .ts and .tsx files with Prettier.yarn build
- -- Regenerates dist` folder that gets included into NPM module.
MIT