Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/benjaminnoufel/tools
- Owner: benjaminnoufel
- License: mit
- Created: 2020-12-20T18:25:25.000Z (about 4 years ago)
- Default Branch: next
- Last Pushed: 2023-01-06T17:28:35.000Z (about 2 years ago)
- Last Synced: 2024-11-22T20:36:23.714Z (3 months ago)
- Topics: javascript, node, typescript, typescript-library, yarn
- Language: TypeScript
- Size: 622 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
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/