micro-fp-tools-js/README.md

59 lines
1.2 KiB
Markdown
Raw Normal View History

2022-02-05 18:14:35 +01:00
# fnTools
2022-02-04 07:31:49 +01:00
2022-02-05 18:14:35 +01:00
Simple functional functions common to any development in Typescript or JavaScript.
2022-02-10 09:25:11 +01:00
## Number
2022-02-05 18:14:35 +01:00
- **inc**: Increase the value of a `number`.
- **dec**: Decrease the value of a `number`.
2022-02-10 09:25:11 +01:00
- **getRandom**: Returns a random number from a range, with an optional number of decimal places.
## Array
2022-02-05 18:14:35 +01:00
- **range**: Returns an array with a sequence.
- **uniqValuesArray**: Creates a duplicate-free version of an array.
2022-02-10 09:25:11 +01:00
- **deleteArrayElementByIndex**: Returns a copy of the array by removing one position by index.
## JSON
2022-02-05 18:14:35 +01:00
- **cloneJSON**: Clone JSON.
- **updateJSON**: Returns a JSON with an updated value.
2022-02-10 09:25:11 +01:00
## File
2022-02-09 16:57:53 +01:00
- **getIndexOfFileList**: Returns the index of an Array of Files from its name. If there are multiple files with the same name, the last one will be returned.
2022-02-10 09:25:11 +01:00
- **arrayFilesToFileList**: Returns a FileLists from an array containing Files.
2022-02-05 18:14:35 +01:00
## Example
2022-02-06 22:26:49 +01:00
```javascript
2022-02-10 09:25:11 +01:00
import {getRandom, range} from 'fnTools.js';
2022-02-06 22:26:49 +01:00
2022-02-10 09:25:11 +01:00
getRandom(0, 6);
2022-02-06 22:26:49 +01:00
// 2
2022-02-05 18:15:27 +01:00
2022-02-10 09:25:11 +01:00
range(4);
2022-02-05 18:15:27 +01:00
// [0, 1, 2, 3, 4]
2022-02-05 18:14:35 +01:00
```
2022-02-06 22:26:49 +01:00
## CDN
```html
<script type="module" src="https://cdn.jsdelivr.net/gh/tanrax/fn-js/dist/fnTools.min.js"></script>
```
2022-02-05 18:14:35 +01:00
## Compile
Install Typescript
2022-02-04 07:31:49 +01:00
```shell
2022-02-05 18:14:35 +01:00
npm install -g typescript
```
And build.
```shell
make build
````
2022-02-09 16:57:53 +01:00
Check 'dist' folder.