Skip to content

prohetamine/forPromise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

forPromise

edit me

lang: ru en

С чего начать

Установим 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 --------

lang: ru en

Get started

Install the npm module forPromise

$ npm install forPromise

or

$ yarn add forPromise

or

$ yarn add https://github.com/prohetamine/forPromise

Examples and description

Connecting 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)
})()

Other examples

more...

Contacts

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.

About

⚙️ While for promise

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published