Skip to content

Commit

Permalink
utils
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieljablonski committed May 13, 2022
1 parent 5c7d058 commit 34cdebc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/utils/formatting.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export function round(number: number, places = 0): number {
const d = 10 ** places;
return Math.round(number * d + Number.EPSILON) / d;
}

export function normalizeText(text: string): string {
return text
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.toLowerCase();
}
4 changes: 4 additions & 0 deletions src/utils/general.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// eslint-disable-next-line import/prefer-default-export
export function hasValue(data: unknown): boolean {
return data !== undefined && data !== null && !Number.isNaN(data);
}
4 changes: 3 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { };
export * from './general';
export * from './formatting';
export * from './typings';
5 changes: 5 additions & 0 deletions src/utils/typings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from 'react';

export interface WithChildren {
children: React.ReactNode;
}

0 comments on commit 34cdebc

Please sign in to comment.