Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prohetamine/forpromise
⚙️ While for promise
https://github.com/prohetamine/forpromise
javascript npm npm-package promise
Last synced: 20 days ago
JSON representation
⚙️ While for promise
- Host: GitHub
- URL: https://github.com/prohetamine/forpromise
- Owner: prohetamine
- Created: 2021-07-02T11:49:16.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-13T12:54:01.000Z (almost 3 years ago)
- Last Synced: 2024-11-19T09:26:23.349Z (3 months ago)
- Topics: javascript, npm, npm-package, promise
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# forPromise
edit me
##### lang: [ru](#rulang) [en](#enlang)
### С чего начать
Установим npm модуль ```forPromise```
```sh
$ npm install forPromise
```или
```sh
$ yarn add forPromise
```или
```sh
$ yarn add https://github.com/prohetamine/forPromise
```### Примеры и описание
Подключение модуля
```sh
const { prototype, forPromise } = require('forPromise')
```#### prototype
Функция [prototype](#prototype) добавляет в прототипы массивов новую функцию forPromise.
| параметры | значение по-умолчанию | информация |
| ------ | ------ | ------ |
| function | undefined | функция обратного вызова должна возвращать промис |```sh
const { prototype } = require('forPromise')
const axios = require('axios')prototype() // inject array prototype
;(async () => {
const arr = [1, 2, 3, 4, 5]const newArr = await arr.forPromise(
id => axios.get(`https://jsonplaceholder.typicode.com/todos/${id}`).then(({ data }) => data)
)console.log(newArr)
})()
```#### forPromise
Функция [forPromise](#for-promise) выполняет массив заданных промисов
| параметры | значение по-умолчанию | информация |
| ------ | ------ | ------ |
| Array | undefined | массив элементов |
| function | undefined | функция обратного вызова должна возвращать промис |```sh
const { forPromise } = require('forPromise')
const axios = require('axios');(async () => {
const arr = [1, 2, 3, 4, 5]const newArr = await forPromise(
arr,
id => axios.get(`https://jsonplaceholder.typicode.com/todos/${id}`).then(({ data }) => data)
)console.log(newArr)
})()
```### Другие примеры
[больше...](/examples)
### Контакты
Мой Телеграм: [@prohetamine](https://t.me/prohetamine), [канал](https://t.me/prohetamine)
Почта: [email protected]
Донат денег: [patreon](https://www.patreon.com/prohetamine)
Если у вас есть какие-либо вопросы и/или предложения, пожалуйста, напишите мне в телеграмме, если вы найдете ошибки также дайте мне знать, я буду очень благодарен.
-------- OTHER WORLD --------
##### lang: [ru](#rulang) [en](#enlang)
### Get started
Install the npm module ```forPromise```
```sh
$ npm install forPromise
```or
```sh
$ yarn add forPromise
```or
```sh
$ yarn add https://github.com/prohetamine/forPromise
```### Examples and description
Connecting the module
```sh
const { prototype, forPromise } = require('forpromise')
```#### prototype
The [prototype](#prototype) function adds a new forPromise function to the array prototypes.
| parameters | default value | information|
| ------ | ------ | ------ |
| function | undefined | the callback function should return a promise |```sh
const { prototype } = require('forPromise')
const axios = require('axios')prototype() // inject array prototype
;(async () => {
const arr = [1, 2, 3, 4, 5]const newArr = await arr.forPromise(
id => axios.get(`https://jsonplaceholder.typicode.com/todos/${id}`).then(({ data }) => data)
)console.log(newArr)
})()
```#### forPromise
The [forPromise](#for-promise) function executes an array of specified promises
| parameters | default value | information|
| ------ | ------ | ------ |
| Array | undefined / array of elements |
| function | undefined | the callback function should return a promise |```sh
const { forPromise } = require('forPromise')
const axios = require('axios');(async () => {
const arr = [1, 2, 3, 4, 5]const newArr = await forPromise(
arr,
id => axios.get(`https://jsonplaceholder.typicode.com/todos/${id}`).then(({ data }) => data)
)console.log(newArr)
})()
```### Other examples
[more...](/examples)
### Contacts
My Telegram: [@prohetamine](https://t.me/prohetamine), [channel](https://t.me/prohetamine)
Email: [email protected]
Donat money: [patreon](https://www.patreon.com/prohetamine)
If you have any questions and/or suggestions, please email me in telegram, if you find any bugs also let me know, I will be very grateful.