edit me
Установим npm модуль forPromise
$ npm install forPromiseили
$ yarn add forPromiseили
$ yarn add https://github.com/prohetamine/forPromiseПодключение модуля
const { prototype, forPromise } = require('forPromise')Функция prototype добавляет в прототипы массивов новую функцию forPromise.
| параметры | значение по-умолчанию | информация |
|---|---|---|
| function | undefined | функция обратного вызова должна возвращать промис |
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 выполняет массив заданных промисов
| параметры | значение по-умолчанию | информация |
|---|---|---|
| Array | undefined | массив элементов |
| function | undefined | функция обратного вызова должна возвращать промис |
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)
})()Мой Телеграм: @prohetamine, канал
Почта: prohetamine@gmail.com
Донат денег: patreon
Если у вас есть какие-либо вопросы и/или предложения, пожалуйста, напишите мне в телеграмме, если вы найдете ошибки также дайте мне знать, я буду очень благодарен.
-------- OTHER WORLD --------
Install the npm module forPromise
$ npm install forPromiseor
$ yarn add forPromiseor
$ yarn add https://github.com/prohetamine/forPromiseConnecting the module
const { prototype, forPromise } = require('forpromise')The prototype function adds a new forPromise function to the array prototypes.
| parameters | default value | information |
|---|---|---|
| function | undefined | the callback function should return a promise |
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)
})()The forPromise 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 |
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)
})()My Telegram: @prohetamine, channel
Email: prohetamine@gmail.com
Donat money: patreon
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.