Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/benjaminnoufel/tools

It's a different collection of tools.
https://github.com/benjaminnoufel/tools

javascript node typescript typescript-library yarn

Last synced: 23 days ago
JSON representation

It's a different collection of tools.

Awesome Lists containing this project

README

        

# @benjaminnoufel/tools

It's a different collection of tools.

![Code Style CI](https://github.com/benjaminnoufel/tools/workflows/Code%20Style%20CI/badge.svg) ![Test CI](https://github.com/benjaminnoufel/tools/workflows/Test%20CI/badge.svg) ![Package](https://github.com/benjaminnoufel/tools/workflows/Package/badge.svg) ![Package npmjs](https://github.com/benjaminnoufel/tools/workflows/Package%20npmjs/badge.svg)

## Requirements

- [NPM][npm] or [Yarn][yarn]

## Installation

### NPM

```console
$ npm install --save @benjaminnoufel/tools
```

### Yarn

```console
$ yarn add @benjaminnoufel/tools
```

## Usage

### Use Validator
```jsx
import {phoneNumberIsValid, passwordIsValid, emailIsValid} from "@benjaminnoufel/tools";
import {useState} from "react";

const App = () => {
const [state, setState] = useState({ password: null, phone: null, email: null})

const handleChange = (e) => {
if (e.target.name === "phone" && phoneNumberIsValid(state.phone)) {
setState({
...state,
phone: e.target.value
})
}
if (e.target.name === "password" && passwordIsValid(state.password)) {
setState({
...state,
password: e.target.value
})
}

if (e.target.name === "email" && emailIsValid(state.email)) {
setState({
...state,
email: e.target.value
})
}
}

return (
<>



>
);
}

```

### Use Format
```jsx
import {formatCurrency, formatDate, formatNumber} from "@benjaminnoufel/tools";

const App = () => {


return (
<>

Price: {formatCurrency("fr-FR", "EUR", 125.89)}


Order date: {formatDate("fr-FR", "01/01/1970")}


Number of items: {formatNumber("fr-FR", 2, 4)}


>
);
}

```

### Use path
```jsx
import {normalizePath} from "@benjaminnoufel/tools";

const App = () => {

const url = "/static//image/logo.png"

return (
<>

Url of logo: http://localhost/{normalizePath(url)}


Order date: {formatDate("fr-FR", "01/01/1970")}


Number of items: {formatNumber("fr-FR", 2, 4)}


>
);
}

```

[npm]: https://www.npmjs.com/
[yarn]: https://yarnpkg.com/